From 09ef7da0954c15f76139aaaf70fa0be633903a52 Mon Sep 17 00:00:00 2001 From: lzx_mac <2602107437@qq.com> Date: Wed, 11 Dec 2024 15:26:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-pc/src/mixins/JeecgListMixin.js | 747 ++++++------- applet-rice-api/applet-rice-api.iml | 1 + applet-rice-api/pom.xml | 4 + .../api/controller/ApiRiceIndexController.java | 11 +- .../java/org/jeecg/api/service/ApiRiceService.java | 6 +- .../jeecg/api/service/impl/ApiRiceServiceImpl.java | 542 ++++++++-- .../main/java/org/jeecg/bean/HttpClientUtil.java | 1122 ++++++++++++++++++++ .../src/main/java/org/jeecg/bean/WxQrCodeVo.java | 14 + .../controller/CommonOrderController.java | 2 +- .../modules/commonOrder/entity/CommonOrder.java | 7 +- .../commonOrder/mapper/CommonOrderMapper.java | 2 +- .../commonOrder/service/ICommonOrderService.java | 2 +- .../service/impl/CommonOrderServiceImpl.java | 2 +- .../modules/commonOrder/vue/CommonOrderList.vue | 22 + .../commonOrder/vue/modules/CommonOrderForm.vue | 5 + .../modules/commonOrder/vue3/CommonOrder.data.ts | 22 + module-system/module-system.iml | 2 +- .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/pay_weixin.properties | 4 +- 19 files changed, 2056 insertions(+), 463 deletions(-) create mode 100644 applet-rice-api/src/main/java/org/jeecg/bean/HttpClientUtil.java create mode 100644 applet-rice-api/src/main/java/org/jeecg/bean/WxQrCodeVo.java diff --git a/admin-pc/src/mixins/JeecgListMixin.js b/admin-pc/src/mixins/JeecgListMixin.js index 2a09ddf..e558537 100644 --- a/admin-pc/src/mixins/JeecgListMixin.js +++ b/admin-pc/src/mixins/JeecgListMixin.js @@ -1,374 +1,375 @@ -/** - * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm - * 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal - * data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除 - */ -import { filterObj } from '@/utils/util'; -import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage' -import Vue from 'vue' -import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types" -import store from '@/store' - -export const JeecgListMixin = { - data(){ - return { - /* 查询条件-请不要在queryParam中声明非字符串值的属性 */ - queryParam: {}, - /* 数据源 */ - dataSource:[], - /* 分页参数 */ - ipagination:{ - current: 1, - pageSize: 10, - pageSizeOptions: ['10', '20', '30'], - showTotal: (total, range) => { - return range[0] + "-" + range[1] + " 共" + total + "条" - }, - showQuickJumper: true, - showSizeChanger: true, - total: 0 - }, - /* 排序参数 */ - isorter:{ - column: 'createTime', - order: 'desc', - }, - /* 筛选参数 */ - filters: {}, - /* table加载状态 */ - loading:false, - /* table选中keys*/ - selectedRowKeys: [], - /* table选中records*/ - selectionRows: [], - /* 查询折叠 */ - toggleSearchStatus:false, - /* 高级查询条件生效状态 */ - superQueryFlag:false, - /* 高级查询条件 */ - superQueryParams: '', - /** 高级查询拼接方式 */ - superQueryMatchType: 'and', - } - }, - created() { - if(!this.disableMixinCreated){ - console.log(' -- mixin created -- ') - this.loadData(); - //初始化字典配置 在自己页面定义 - this.initDictConfig(); - } - }, - computed: { - //token header - tokenHeader(){ - let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)} - let tenantid = Vue.ls.get(TENANT_ID) - if(tenantid){ - head['tenant-id'] = tenantid - } - return head; - } - }, - methods:{ - loadData(arg) { - if(!this.url.list){ - this.$message.error("请设置url.list属性!") - return - } - //加载数据 若传入参数1则加载第一页的内容 - if (arg === 1) { - this.ipagination.current = 1; - } - var params = this.getQueryParams();//查询条件 - this.loading = true; - getAction(this.url.list, params).then((res) => { - if (res.success) { - //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ - this.dataSource = res.result.records||res.result; - if(res.result.total) - { - this.ipagination.total = res.result.total; - }else{ - this.ipagination.total = 0; - } - //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ - }else{ - this.$message.warning(res.message) - } - }).finally(() => { - this.loading = false - }) - }, - initDictConfig(){ - console.log("--这是一个假的方法!") - }, - handleSuperQuery(params, matchType) { - //高级查询方法 - if(!params){ - this.superQueryParams='' - this.superQueryFlag = false - }else{ - this.superQueryFlag = true - this.superQueryParams=JSON.stringify(params) - this.superQueryMatchType = matchType - } - this.loadData(1) - }, - getQueryParams() { - //获取查询条件 - let sqp = {} - if(this.superQueryParams){ - sqp['superQueryParams']=encodeURI(this.superQueryParams) - sqp['superQueryMatchType'] = this.superQueryMatchType - } - var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters); - param.field = this.getQueryField(); - param.pageNo = this.ipagination.current; - param.pageSize = this.ipagination.pageSize; - return filterObj(param); - }, - getQueryField() { - //TODO 字段权限控制 - var str = "id,"; - this.columns.forEach(function (value) { - str += "," + value.dataIndex; - }); - return str; - }, - - onSelectChange(selectedRowKeys, selectionRows) { - this.selectedRowKeys = selectedRowKeys; - this.selectionRows = selectionRows; - }, - onClearSelected() { - this.selectedRowKeys = []; - this.selectionRows = []; - }, - searchQuery() { - this.loadData(1); - // 点击查询清空列表选中行 - // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1 - this.selectedRowKeys = [] - this.selectionRows = [] - }, - superQuery() { - this.$refs.superQueryModal.show(); - }, - searchReset() { - this.queryParam = {} - this.loadData(1); - }, - batchDel: function () { - if(!this.url.deleteBatch){ - this.$message.error("请设置url.deleteBatch属性!") - return - } - if (this.selectedRowKeys.length <= 0) { - this.$message.warning('请选择一条记录!'); - return; - } else { - var ids = ""; - for (var a = 0; a < this.selectedRowKeys.length; a++) { - ids += this.selectedRowKeys[a] + ","; - } - var that = this; - this.$confirm({ - title: "确认删除", - content: "是否删除选中数据?", - onOk: function () { - that.loading = true; - deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => { - if (res.success) { - //重新计算分页问题 - that.reCalculatePage(that.selectedRowKeys.length) - that.$message.success(res.message); - that.loadData(); - that.onClearSelected(); - } else { - that.$message.warning(res.message); - } - }).finally(() => { - that.loading = false; - }); - } - }); - } - }, - handleDelete: function (id) { - if(!this.url.delete){ - this.$message.error("请设置url.delete属性!") - return - } - var that = this; - deleteAction(that.url.delete, {id: id}).then((res) => { - if (res.success) { - //重新计算分页问题 - that.reCalculatePage(1) - that.$message.success(res.message); - that.loadData(); - } else { - that.$message.warning(res.message); - } - }); - }, - reCalculatePage(count){ - //总数量-count - let total=this.ipagination.total-count; - //获取删除后的分页数 - let currentIndex=Math.ceil(total/this.ipagination.pageSize); - //删除后的分页数<所在当前页 - if(currentIndex 0) { - this.isorter.column = sorter.field; - this.isorter.order = "ascend" == sorter.order ? "asc" : "desc" - } - this.ipagination = pagination; - this.loadData(); - }, - handleToggleSearch(){ - this.toggleSearchStatus = !this.toggleSearchStatus; - }, - // 给popup查询使用(查询区域不支持回填多个字段,限制只返回一个字段) - getPopupField(fields){ - return fields.split(',')[0] - }, - modalFormOk() { - // 新增/修改 成功时,重载列表 - this.loadData(); - //清空列表选中 - this.onClearSelected() - }, - handleDetail:function(record){ - this.$refs.modalForm.edit(record); - this.$refs.modalForm.title="详情"; - this.$refs.modalForm.disableSubmit = true; - }, - /* 导出 */ - handleExportXls2(){ - let paramsStr = encodeURI(JSON.stringify(this.getQueryParams())); - let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`; - window.location.href = url; - }, - handleExportXls(fileName){ - if(!fileName || typeof fileName != "string"){ - fileName = "导出文件" - } - let param = this.getQueryParams(); - if(this.selectedRowKeys && this.selectedRowKeys.length>0){ - param['selections'] = this.selectedRowKeys.join(",") - } - console.log("导出参数",param) - downFile(this.url.exportXlsUrl,param).then((data)=>{ - if (!data) { - this.$message.warning("文件下载失败") - return - } - if (typeof window.navigator.msSaveBlob !== 'undefined') { - window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls') - }else{ - let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'})) - let link = document.createElement('a') - link.style.display = 'none' - link.href = url - link.setAttribute('download', fileName+'.xls') - document.body.appendChild(link) - link.click() - document.body.removeChild(link); //下载完成移除元素 - window.URL.revokeObjectURL(url); //释放掉blob对象 - } - }) - }, - /* 导入 */ - handleImportExcel(info){ - this.loading = true; - if (info.file.status !== 'uploading') { - console.log(info.file, info.fileList); - } - if (info.file.status === 'done') { - this.loading = false; - if (info.file.response.success) { - // this.$message.success(`${info.file.name} 文件上传成功`); - if (info.file.response.code === 201) { - let { message, result: { msg, fileUrl, fileName } } = info.file.response - let href = window._CONFIG['domianURL'] + fileUrl - this.$warning({ - title: message, - content: (
- {msg}
- 具体详情请 点击下载 -
- ) - }) - } else { - this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`) - } - this.loadData() - } else { - this.$message.error(`${info.file.name} ${info.file.response.message}.`); - } - } else if (info.file.status === 'error') { - this.loading = false; - if (info.file.response.status === 500) { - let data = info.file.response - const token = Vue.ls.get(ACCESS_TOKEN) - if (token && data.message.includes("Token失效")) { - this.$error({ - title: '登录已过期', - content: '很抱歉,登录已过期,请重新登录', - okText: '重新登录', - mask: false, - onOk: () => { - store.dispatch('Logout').then(() => { - Vue.ls.remove(ACCESS_TOKEN) - window.location.reload(); - }) - } - }) - } - } else { - this.$message.error(`文件上传失败: ${info.file.msg} `); - } - } - }, - /* 图片预览 */ - getImgView(text){ - if(text && text.indexOf(",")>0){ - text = text.substring(0,text.indexOf(",")) - } - return getFileAccessHttpUrl(text) - }, - /* 文件下载 */ - // update--autor:lvdandan-----date:20200630------for:修改下载文件方法名uploadFile改为downloadFile------ - downloadFile(text){ - if(!text){ - this.$message.warning("未知的文件") - return; - } - if(text.indexOf(",")>0){ - text = text.substring(0,text.indexOf(",")) - } - let url = getFileAccessHttpUrl(text) - window.open(url); - }, - } - +/** + * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm + * 高级查询按钮调用 superQuery方法 高级查询组件ref定义为superQueryModal + * data中url定义 list为查询列表 delete为删除单条记录 deleteBatch为批量删除 + */ +import { filterObj } from '@/utils/util'; +import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage' +import Vue from 'vue' +import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types" +import store from '@/store' + +export const JeecgListMixin = { + data(){ + return { + /* 查询条件-请不要在queryParam中声明非字符串值的属性 */ + queryParam: {}, + /* 数据源 */ + dataSource:[], + /* 分页参数 */ + ipagination:{ + current: 1, + pageSize: 10, + pageSizeOptions: ['10', '20', '30'], + showTotal: (total, range) => { + return range[0] + "-" + range[1] + " 共" + total + "条" + }, + showQuickJumper: true, + showSizeChanger: true, + total: 0 + }, + /* 排序参数 */ + isorter:{ + column: 'createTime', + order: 'desc', + }, + /* 筛选参数 */ + filters: {}, + /* table加载状态 */ + loading:false, + /* table选中keys*/ + selectedRowKeys: [], + /* table选中records*/ + selectionRows: [], + /* 查询折叠 */ + toggleSearchStatus:false, + /* 高级查询条件生效状态 */ + superQueryFlag:false, + /* 高级查询条件 */ + superQueryParams: '', + /** 高级查询拼接方式 */ + superQueryMatchType: 'and', + } + }, + created() { + if(!this.disableMixinCreated){ + console.log(' -- mixin created -- ') + this.loadData(); + //初始化字典配置 在自己页面定义 + this.initDictConfig(); + } + }, + computed: { + //token header + tokenHeader(){ + let head = {'X-Access-Token': Vue.ls.get(ACCESS_TOKEN)} + let tenantid = Vue.ls.get(TENANT_ID) + if(tenantid){ + head['tenant-id'] = tenantid + } + return head; + } + }, + methods:{ + loadData(arg) { + if(!this.url.list){ + this.$message.error("请设置url.list属性!") + return + } + //加载数据 若传入参数1则加载第一页的内容 + if (arg === 1) { + this.ipagination.current = 1; + } + var params = this.getQueryParams();//查询条件 + this.loading = true; + getAction(this.url.list, params).then((res) => { + if (res.success) { + //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ + this.dataSource = res.result.records||res.result; + if(res.result.total) + { + this.ipagination.total = res.result.total; + }else{ + this.ipagination.total = 0; + } + //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------ + }else{ + this.$message.warning(res.message) + } + }).finally(() => { + this.loading = false + }) + }, + initDictConfig(){ + console.log("--这是一个假的方法!") + }, + handleSuperQuery(params, matchType) { + //高级查询方法 + if(!params){ + this.superQueryParams='' + this.superQueryFlag = false + }else{ + this.superQueryFlag = true + this.superQueryParams=JSON.stringify(params) + this.superQueryMatchType = matchType + } + this.loadData(1) + }, + getQueryParams() { + //获取查询条件 + let sqp = {} + if(this.superQueryParams){ + sqp['superQueryParams']=encodeURI(this.superQueryParams) + sqp['superQueryMatchType'] = this.superQueryMatchType + } + var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters); + param.field = this.getQueryField(); + param.pageNo = this.ipagination.current; + param.pageSize = this.ipagination.pageSize; + return filterObj(param); + }, + getQueryField() { + //TODO 字段权限控制 + var str = "id,"; + this.columns.forEach(function (value) { + str += "," + value.dataIndex; + }); + return str; + }, + + onSelectChange(selectedRowKeys, selectionRows) { + this.selectedRowKeys = selectedRowKeys; + this.selectionRows = selectionRows; + }, + onClearSelected() { + this.selectedRowKeys = []; + this.selectionRows = []; + }, + searchQuery() { + this.loadData(1); + // 点击查询清空列表选中行 + // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1 + this.selectedRowKeys = [] + this.selectionRows = [] + }, + superQuery() { + this.$refs.superQueryModal.show(); + }, + searchReset() { + this.queryParam = {} + this.loadData(1); + }, + batchDel: function () { + if(!this.url.deleteBatch){ + this.$message.error("请设置url.deleteBatch属性!") + return + } + if (this.selectedRowKeys.length <= 0) { + this.$message.warning('请选择一条记录!'); + return; + } else { + var ids = ""; + for (var a = 0; a < this.selectedRowKeys.length; a++) { + ids += this.selectedRowKeys[a] + ","; + } + var that = this; + this.$confirm({ + title: "确认删除", + content: "是否删除选中数据?", + onOk: function () { + that.loading = true; + deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => { + if (res.success) { + //重新计算分页问题 + that.reCalculatePage(that.selectedRowKeys.length) + that.$message.success(res.message); + that.loadData(); + that.onClearSelected(); + } else { + that.$message.warning(res.message); + } + }).finally(() => { + that.loading = false; + }); + } + }); + } + }, + handleDelete: function (id) { + if(!this.url.delete){ + this.$message.error("请设置url.delete属性!") + return + } + var that = this; + deleteAction(that.url.delete, {id: id}).then((res) => { + if (res.success) { + //重新计算分页问题 + that.reCalculatePage(1) + that.$message.success(res.message); + that.loadData(); + } else { + that.$message.warning(res.message); + } + }); + + }, + reCalculatePage(count){ + //总数量-count + let total=this.ipagination.total-count; + //获取删除后的分页数 + let currentIndex=Math.ceil(total/this.ipagination.pageSize); + //删除后的分页数<所在当前页 + if(currentIndex 0) { + this.isorter.column = sorter.field; + this.isorter.order = "ascend" == sorter.order ? "asc" : "desc" + } + this.ipagination = pagination; + this.loadData(); + }, + handleToggleSearch(){ + this.toggleSearchStatus = !this.toggleSearchStatus; + }, + // 给popup查询使用(查询区域不支持回填多个字段,限制只返回一个字段) + getPopupField(fields){ + return fields.split(',')[0] + }, + modalFormOk() { + // 新增/修改 成功时,重载列表 + this.loadData(); + //清空列表选中 + this.onClearSelected() + }, + handleDetail:function(record){ + this.$refs.modalForm.edit(record); + this.$refs.modalForm.title="详情"; + this.$refs.modalForm.disableSubmit = true; + }, + /* 导出 */ + handleExportXls2(){ + let paramsStr = encodeURI(JSON.stringify(this.getQueryParams())); + let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`; + window.location.href = url; + }, + handleExportXls(fileName){ + if(!fileName || typeof fileName != "string"){ + fileName = "导出文件" + } + let param = this.getQueryParams(); + if(this.selectedRowKeys && this.selectedRowKeys.length>0){ + param['selections'] = this.selectedRowKeys.join(",") + } + console.log("导出参数",param) + downFile(this.url.exportXlsUrl,param).then((data)=>{ + if (!data) { + this.$message.warning("文件下载失败") + return + } + if (typeof window.navigator.msSaveBlob !== 'undefined') { + window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls') + }else{ + let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'})) + let link = document.createElement('a') + link.style.display = 'none' + link.href = url + link.setAttribute('download', fileName+'.xls') + document.body.appendChild(link) + link.click() + document.body.removeChild(link); //下载完成移除元素 + window.URL.revokeObjectURL(url); //释放掉blob对象 + } + }) + }, + /* 导入 */ + handleImportExcel(info){ + this.loading = true; + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + if (info.file.status === 'done') { + this.loading = false; + if (info.file.response.success) { + // this.$message.success(`${info.file.name} 文件上传成功`); + if (info.file.response.code === 201) { + let { message, result: { msg, fileUrl, fileName } } = info.file.response + let href = window._CONFIG['domianURL'] + fileUrl + this.$warning({ + title: message, + content: (
+ {msg}
+ 具体详情请 点击下载 +
+ ) + }) + } else { + this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`) + } + this.loadData() + } else { + this.$message.error(`${info.file.name} ${info.file.response.message}.`); + } + } else if (info.file.status === 'error') { + this.loading = false; + if (info.file.response.status === 500) { + let data = info.file.response + const token = Vue.ls.get(ACCESS_TOKEN) + if (token && data.message.includes("Token失效")) { + this.$error({ + title: '登录已过期', + content: '很抱歉,登录已过期,请重新登录', + okText: '重新登录', + mask: false, + onOk: () => { + store.dispatch('Logout').then(() => { + Vue.ls.remove(ACCESS_TOKEN) + window.location.reload(); + }) + } + }) + } + } else { + this.$message.error(`文件上传失败: ${info.file.msg} `); + } + } + }, + /* 图片预览 */ + getImgView(text){ + if(text && text.indexOf(",")>0){ + text = text.substring(0,text.indexOf(",")) + } + return getFileAccessHttpUrl(text) + }, + /* 文件下载 */ + // update--autor:lvdandan-----date:20200630------for:修改下载文件方法名uploadFile改为downloadFile------ + downloadFile(text){ + if(!text){ + this.$message.warning("未知的文件") + return; + } + if(text.indexOf(",")>0){ + text = text.substring(0,text.indexOf(",")) + } + let url = getFileAccessHttpUrl(text) + window.open(url); + }, + } + } \ No newline at end of file diff --git a/applet-rice-api/applet-rice-api.iml b/applet-rice-api/applet-rice-api.iml index abca61b..cdbe7f2 100644 --- a/applet-rice-api/applet-rice-api.iml +++ b/applet-rice-api/applet-rice-api.iml @@ -263,6 +263,7 @@ + diff --git a/applet-rice-api/pom.xml b/applet-rice-api/pom.xml index 52d3be0..65be46d 100644 --- a/applet-rice-api/pom.xml +++ b/applet-rice-api/pom.xml @@ -48,6 +48,10 @@ 3.2.0 compile + + commons-fileupload + commons-fileupload + diff --git a/applet-rice-api/src/main/java/org/jeecg/api/controller/ApiRiceIndexController.java b/applet-rice-api/src/main/java/org/jeecg/api/controller/ApiRiceIndexController.java index 29ff1f2..086c45e 100644 --- a/applet-rice-api/src/main/java/org/jeecg/api/controller/ApiRiceIndexController.java +++ b/applet-rice-api/src/main/java/org/jeecg/api/controller/ApiRiceIndexController.java @@ -164,6 +164,13 @@ public class ApiRiceIndexController { } + //创建订单 + @ApiOperation(value="创建订单-再次支付", notes="创建订单-再次支付") + @GetMapping(value = "/createOrderTwo") + public Result createOrderTwo(@RequestHeader("X-Access-Token") String token,String orderId) { + return apiRiceService.createOrderTwo(token,orderId); + } + //商城-加入购物车之后一次下多个订单 @ApiOperation(value="商城-加入购物车之后一次下多个订单", notes="商城-加入购物车之后一次下多个订单") @@ -177,8 +184,8 @@ public class ApiRiceIndexController { //商城-加入购物车之后一次下多个订单 - 再次下单 @ApiOperation(value="商城-加入购物车之后一次下多个订单 - 再次下单", notes="商城-加入购物车之后一次下多个订单 - 再次下单") @PostMapping("/createSumOrderAgain") - public Result createSumOrderAgain(@RequestHeader("X-Access-Token") String token,String list,String addressId,String orderId){ - return apiRiceService.createSumOrderAgain(token,list,addressId,orderId); + public Result createSumOrderAgain(@RequestHeader("X-Access-Token") String token,String orderId){ + return apiRiceService.createSumOrderAgain(token,orderId); } diff --git a/applet-rice-api/src/main/java/org/jeecg/api/service/ApiRiceService.java b/applet-rice-api/src/main/java/org/jeecg/api/service/ApiRiceService.java index a2842bf..2f19b64 100644 --- a/applet-rice-api/src/main/java/org/jeecg/api/service/ApiRiceService.java +++ b/applet-rice-api/src/main/java/org/jeecg/api/service/ApiRiceService.java @@ -49,11 +49,15 @@ public interface ApiRiceService { Result createOrder(String token,String productId,Integer num,String addressId); + //再次支付 + Result createOrderTwo(String token,String orderId); + + //商城-立即购买多少商品 Result createSumOrder(String token,String list,String addressId); //商城-加入购物车之后一次下多个订单 - 再次下单 - Result createSumOrderAgain(String token,String list,String addressId,String orderId); + Result createSumOrderAgain(String token,String orderId); //商城-支付回调 diff --git a/applet-rice-api/src/main/java/org/jeecg/api/service/impl/ApiRiceServiceImpl.java b/applet-rice-api/src/main/java/org/jeecg/api/service/impl/ApiRiceServiceImpl.java index 608188a..6fb8acb 100644 --- a/applet-rice-api/src/main/java/org/jeecg/api/service/impl/ApiRiceServiceImpl.java +++ b/applet-rice-api/src/main/java/org/jeecg/api/service/impl/ApiRiceServiceImpl.java @@ -1,6 +1,9 @@ package org.jeecg.api.service.impl; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.IdWorker; @@ -9,8 +12,12 @@ import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; import lombok.extern.log4j.Log4j; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.jeecg.api.service.ApiRiceService; +import org.jeecg.bean.HttpClientUtil; import org.jeecg.bean.PageBean; +import org.jeecg.bean.WxQrCodeVo; import org.jeecg.common.api.vo.Result; import org.jeecg.config.shiro.ShiroRealm; import org.jeecg.modules.commonAddress.entity.CommonAddress; @@ -21,6 +28,7 @@ import org.jeecg.modules.commonCat.entity.CommonCat; import org.jeecg.modules.commonCat.service.ICommonCatService; import org.jeecg.modules.commonClass.entity.CommonClass; import org.jeecg.modules.commonClass.service.ICommonClassService; +import org.jeecg.modules.commonConfig.entity.CommonConfig; import org.jeecg.modules.commonConfig.service.ICommonConfigService; import org.jeecg.modules.commonIconImage.entity.CommonIconImage; import org.jeecg.modules.commonIconImage.service.ICommonIconImageService; @@ -45,11 +53,22 @@ import org.jeecg.modules.riceNews.entity.RiceNews; import org.jeecg.modules.riceNews.service.IRiceNewsService; import org.jeecg.modules.riceVip.entity.RiceVip; import org.jeecg.modules.riceVip.service.IRiceVipService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.annotation.Resource; +import javax.transaction.Transactional; +import java.io.*; import java.math.BigDecimal; import java.util.*; @@ -205,6 +224,126 @@ public class ApiRiceServiceImpl implements ApiRiceService { } + //再次支付 + @Override + @Transactional + public Result createOrderTwo(String token,String orderId){ + HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiOpenId(token); + //查询订单是否存在 + CommonOrder commonOrder = commonOrderService.getById(orderId); + if (commonOrder==null){ + return Result.error("订单不存在"); + } + if (commonOrder.getState()==1){ + return Result.error("订单已支付"); + } + //查询订单是否shopState不等于2 + if (commonOrder.getShopState()==2){ + return Result.error("非首页订单"); + } + +//根据配置列表查询每人限制数量 + CommonConfig commonConfig = commonConfigService.lambdaQuery() + .eq(CommonConfig::getKeyName,"pay_num") + .one(); + //得到配置的数值转为int类型 + int payNum = Integer.parseInt(commonConfig.getKeyContent()); + //根据商品信息是否是体验装进行判断 + if (commonOrder.getShopState()==0){ + //查询用户是否存在该订单 + List byUserIdAndShopId = commonOrderService.lambdaQuery() + .eq(CommonOrder::getUserId,hanHaiMember.getId()) + .eq(CommonOrder::getShopId,commonOrder.getShopId()) + .eq(CommonOrder::getShopState,0) + .eq(CommonOrder::getState,1) + .list(); + if (byUserIdAndShopId.size()+1>payNum){ + return Result.error("已超过体验商品购买次数限制!请勿重复购买"); + } + + //查询用户是否存在该订单 + List payNumList = commonOrderService.lambdaQuery() + .eq(CommonOrder::getUserId,hanHaiMember.getId()) + .eq(CommonOrder::getShopId,commonOrder.getShopId()) + .eq(CommonOrder::getShopState,0) + .eq(CommonOrder::getState,0) + .list(); + if (payNumList.size()>1){ + return Result.error("您有相同订单未付款!请先付款"); + } + } + + + + + //创建订单标识 + String newOrderId = IdWorker.getIdStr(); + //老的订单数据复制给新创建的订单对象 + CommonOrder commonOrder1 = new CommonOrder(); + commonOrder1.setId(newOrderId); + commonOrder1.setShopState(commonOrder.getShopState()); + commonOrder1.setUserId(hanHaiMember.getId()); + commonOrder1.setTitle(commonOrder.getTitle()); + commonOrder1.setImage(commonOrder.getImage()); + commonOrder1.setPrice(commonOrder.getPrice()); + commonOrder1.setNum(commonOrder.getNum()); + commonOrder1.setShopId(commonOrder.getShopId()); + commonOrder1.setPayNo(commonOrder.getPayNo()); + commonOrder1.setAddressId(commonOrder.getAddressId()); + commonOrder1.setAddressDetails(commonOrder.getAddressDetails()); + commonOrder1.setAddress(commonOrder.getAddress()); + commonOrder1.setName(commonOrder.getName()); + commonOrder1.setPhone(commonOrder.getPhone()); + commonOrder1.setSku(commonOrder.getSku()); + commonOrder1.setCreateTime(new Date()); + commonOrderService.save(commonOrder1); + + + + + + + + + + //根据订单标识查询订单详情对象 + CommonOrderSku commonOrderSku = new CommonOrderSku(); + commonOrderSku.setOrderId(newOrderId); + commonOrderSku.setUserId(hanHaiMember.getId()); + commonOrderSku.setTitle(commonOrder.getTitle()); + commonOrderSku.setImage(commonOrder.getImage()); + commonOrderSku.setPrice(commonOrder.getPrice()); + commonOrderSku.setNum(commonOrder.getNum()); + commonOrderSku.setShopId(commonOrder.getShopId()); + commonOrderSku.setSku(commonOrder.getSku()); + commonOrderSku.setCreateTime(new Date()); + commonOrderSkuService.save(commonOrderSku); + + //删除原订单 + commonOrderService.removeById(orderId); + //查询订单关联的订单详情 + CommonOrderSku one = commonOrderSkuService.lambdaQuery().eq(CommonOrderSku::getOrderId, orderId) + .one(); + //删除该订单详情 + commonOrderSkuService.removeById(one); + + + + //吊起微信支付 + String s = commonOrder1.getPrice().multiply(new BigDecimal(100)).toString(); + int i1 = Double.valueOf(s).intValue(); + Object appOrder = mpWxPayService.createOrder( + "购买"+ commonOrder1.getTitle() , + "127.0.0.1", + orderId, + i1, + orderId, + hanHaiMember.getAppletOpenid(), + commonOrder.toString()); + + return Result.OK("支付成功",appOrder); + } + //创建订单 @Override public Result createOrder(String token,String productId,Integer num,String addressId) { @@ -232,10 +371,45 @@ public class ApiRiceServiceImpl implements ApiRiceService { if (commonAddress==null){ return Result.error("地址不存在"); } + + + //根据配置列表查询每人限制数量 + CommonConfig commonConfig = commonConfigService.lambdaQuery() + .eq(CommonConfig::getKeyName,"pay_num") + .one(); + //得到配置的数值转为int类型 + int payNum = Integer.parseInt(commonConfig.getKeyContent()); + //根据商品信息是否是体验装进行判断 + if (commonShop.getType()==0){ + //查询用户是否存在该订单 + List byUserIdAndShopId = commonOrderService.lambdaQuery() + .eq(CommonOrder::getUserId,hanHaiMember.getId()) + .eq(CommonOrder::getShopId,productId) + .eq(CommonOrder::getShopState,0) + .eq(CommonOrder::getState,1) + .list(); + if (byUserIdAndShopId.size()+1>payNum){ + return Result.error("已超过体验商品购买次数限制!请勿重复购买"); + } + + //查询用户是否存在该订单 + List payNumList = commonOrderService.lambdaQuery() + .eq(CommonOrder::getUserId,hanHaiMember.getId()) + .eq(CommonOrder::getShopId,productId) + .eq(CommonOrder::getShopState,0) + .eq(CommonOrder::getState,0) + .list(); + if (payNumList.size()>0){ + return Result.error("您有相同订单未付款!请先付款"); + } + } + + //创建订单标识 String orderId = IdWorker.getIdStr(); //创建订单 BigDecimal price = commonShop.getPrice().multiply(new BigDecimal(num)); + //生成订单信息 CommonOrder commonOrder = new CommonOrder(); @@ -243,7 +417,7 @@ public class ApiRiceServiceImpl implements ApiRiceService { commonOrder.setTitle(commonShop.getTitle()); commonOrder.setShopId(commonShop.getId()); commonOrder.setImage(commonShop.getImage()); - commonOrder.setState(1); + commonOrder.setState(0); commonOrder.setPrice(price); commonOrder.setNum(num); commonOrder.setSku(commonShop.getSku()); @@ -251,8 +425,10 @@ public class ApiRiceServiceImpl implements ApiRiceService { commonOrder.setPhone(commonAddress.getPhone()); commonOrder.setAddress(commonAddress.getAddress()); commonOrder.setAddressDetails(commonAddress.getAddressDetails()); + commonOrder.setUserId(hanHaiMember.getId()); commonOrder.setAddressId(addressId); + commonOrder.setShopState(commonShop.getType()); commonOrderService.save(commonOrder); //创建订单详情 @@ -317,6 +493,13 @@ public class ApiRiceServiceImpl implements ApiRiceService { //创建订单 BigDecimal price = commonShop.getPrice().multiply(new BigDecimal(sku.getNum())); + + //获取vip价格 + if(hanHaiMember.getIsPay() == 1){ + price = commonShop.getVipPrice().multiply(new BigDecimal(sku.getNum())); + } + + sku.setOrderId(orderId); sku.setShopId(commonShop.getId()); sku.setTitle(commonShop.getTitle()); @@ -349,8 +532,10 @@ public class ApiRiceServiceImpl implements ApiRiceService { cityOrder.setName(commonAddress.getName()); cityOrder.setPhone(commonAddress.getPhone()); cityOrder.setAddressDetails(commonAddress.getAddressDetails()); + cityOrder.setAddressId(addressId); cityOrder.setName("店铺订单"); cityOrder.setPrice(totalPrice); + cityOrder.setShopState(2); cityOrder.setImage(null); cityOrder.setState(0); @@ -379,13 +564,18 @@ public class ApiRiceServiceImpl implements ApiRiceService { //商城-加入购物车之后一次下多个订单 - 再次下单 @Override - public Result createSumOrderAgain(String token,String list,String addressId,String order){ + public Result createSumOrderAgain(String token,String order){ HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiOpenId(token); //根据订单标识查询订单是否存在 - CommonOrder commonOrder = commonOrderService.getById(order); - if (commonOrder==null){ + CommonOrder oldOrder = commonOrderService.getById(order); + if (oldOrder==null){ return Result.error("订单不存在"); } + //储存地址标识 + String addressId = oldOrder.getAddressId(); + //创建订单标识 + String orderId = IdWorker.getIdStr(); + //根据订单标识查询订单详情列表 List commonOrderSkuList = commonOrderSkuService.lambdaQuery() .eq(CommonOrderSku::getOrderId,order) @@ -393,9 +583,12 @@ public class ApiRiceServiceImpl implements ApiRiceService { if (commonOrderSkuList==null || commonOrderSkuList.size()==0){ return Result.error("订单详情不存在"); } + //循环修改订单标识 + for (CommonOrderSku commonOrderSku : commonOrderSkuList) { + commonOrderSku.setOrderId(orderId); + commonOrderSkuService.updateById(commonOrderSku); + } - //如果集合存在循环删除 - commonOrderSkuService.remove(new QueryWrapper().eq("order_id",order)); //用户地址不能为空 @@ -407,83 +600,46 @@ public class ApiRiceServiceImpl implements ApiRiceService { if (commonAddress==null){ return Result.error("地址不存在"); } - //把list转为对象 list = [{"shopId":"1","num":1},{"shopId":"2","num":2}] - List list1 = JSON.parseArray(list, CommonOrderSku.class); - //创建订单标识 - String orderId = IdWorker.getIdStr(); - if(null!=list1 && list1.size()>0){ - //订单总额 - BigDecimal totalPrice = new BigDecimal(0); - //订单商品数量 - Integer totalNum = 0; - //创建订单详情 - for (CommonOrderSku sku : list1) { - //查询商品信息 - CommonShop commonShop = commonShopService.getById(sku.getShopId()); - //商品不能为空 - if (commonShop==null){ - return Result.error("商品不存在"); - } - //创建订单 - BigDecimal price = commonShop.getPrice().multiply(new BigDecimal(sku.getNum())); - - sku.setOrderId(orderId); - sku.setShopId(commonShop.getId()); - sku.setTitle(commonShop.getTitle()); - sku.setImage(commonShop.getImage()); - sku.setPrice(price); - sku.setNum(sku.getNum()); - sku.setSku(commonShop.getSku()); - sku.setCreateTime(new Date()); - sku.setPrice(price); - - sku.setImage(commonShop.getImage()); - sku.setCreateTime(new Date()); - sku.setOrderId(orderId); - commonOrderSkuService.save(sku); - - //计算总价格 - totalPrice = totalPrice.add(price); + //创建主订单 + CommonOrder cityOrder = new CommonOrder(); + cityOrder.setId(orderId); + cityOrder.setUserId(oldOrder.getUserId()); + cityOrder.setShopId(null); + cityOrder.setNum(oldOrder.getNum()); + cityOrder.setAddress(oldOrder.getAddress()); + cityOrder.setName(oldOrder.getName()); + cityOrder.setPhone(oldOrder.getPhone()); + cityOrder.setAddressDetails(oldOrder.getAddressDetails()); + cityOrder.setAddressId(addressId); + cityOrder.setName("店铺订单"); - totalNum = totalNum + sku.getNum(); - } + cityOrder.setPrice(oldOrder.getPrice()); + cityOrder.setImage(null); + cityOrder.setState(0); + cityOrder.setShopState(2); + cityOrder.setCreateTime(new Date()); - //创建主订单 - CommonOrder cityOrder = new CommonOrder(); - cityOrder.setId(orderId); - cityOrder.setUserId(hanHaiMember.getId()); - cityOrder.setShopId(null); - cityOrder.setNum(totalNum); - cityOrder.setAddress(commonAddress.getAddress()); - cityOrder.setName(commonAddress.getName()); - cityOrder.setPhone(commonAddress.getPhone()); - cityOrder.setAddressDetails(commonAddress.getAddressDetails()); - cityOrder.setName("店铺订单"); - cityOrder.setPrice(totalPrice); + commonOrderService.save(cityOrder); - cityOrder.setImage(null); - cityOrder.setState(0); - cityOrder.setCreateTime(new Date()); + //删除旧订单 + commonOrderService.removeById(order); - commonOrderService.save(cityOrder); + //吊起微信支付 + String s = oldOrder.getPrice().multiply(new BigDecimal(100)).toString(); + int i1 = Double.valueOf(s).intValue(); + Object appOrder = mpWxPayService.createOrder( + "购买"+ "店铺订单" , + "127.0.0.1", + orderId, + i1, + orderId, + hanHaiMember.getAppletOpenid(), + cityOrder.toString()); - //吊起微信支付 - String s = totalPrice.multiply(new BigDecimal(100)).toString(); - int i1 = Double.valueOf(s).intValue(); - Object appOrder = mpWxPayService.createOrder( - "购买"+ "店铺订单" , - "127.0.0.1", - orderId, - i1, - orderId, - hanHaiMember.getAppletOpenid(), - cityOrder.toString()); + return Result.OK("支付成功",appOrder); - return Result.OK("支付成功",appOrder); - } - return null; } @@ -497,8 +653,24 @@ public class ApiRiceServiceImpl implements ApiRiceService { CommonOrder commonOrder = commonOrderService.getById(outTradeNo); //如果订单存在则修改订单状态 if (commonOrder!=null){ - commonOrder.setState(1); - commonOrderService.updateById(commonOrder); + if(commonOrder.getState()==0){ + commonOrder.setState(1); + commonOrderService.updateById(commonOrder); + } + + + //如果这个订单是普通订单 + if (commonOrder.getShopState()==2){ + //获得这个订单的总价 + BigDecimal price = commonOrder.getPrice(); + //如果总价超过1000元则修改用户为会员 + if (price.compareTo(new BigDecimal(0.01))==1){ + //查询购买订单的用户信息 + HanHaiMember hanHaiMember = hanHaiMemberService.getById(commonOrder.getUserId()); + hanHaiMember.setIsPay(1); + hanHaiMemberService.updateById(hanHaiMember); + } + } } return null; @@ -656,12 +828,225 @@ public class ApiRiceServiceImpl implements ApiRiceService { return Result.OK(page); } - //获取个人邀请码 + + + private String appid = "wx0839bc52e7849c13"; + + private String secret = "c614fd865951c5246e849501204e6f7f"; + + private String endpoint = "oss-cn-shenzhen.aliyuncs.com"; + + private String accessKey = "LTAI5tQSs47izVy8DLVdwUU9"; + + private String secretKey = "qHI7C3PaXYZySr84HTToviC71AYlFq"; + + private String bucketName = "hanhaiimage"; + + + + + + + private static final String APP_ID = "wx0839bc52e7849c13"; + private static final String APP_SECRET = "c614fd865951c5246e849501204e6f7f"; + private static final String TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + APP_ID + "&secret=" + APP_SECRET; + private static final String TEMPLATE_MESSAGE_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="; + + + + //获取推广二维码 @Override public Result getInviteCode(String token){ + HanHaiMember member = shiroRealm.checkUserTokenIsEffectHanHaiOpenId(token); + + CommonConfig vsion = commonConfigService.lambdaQuery() + .eq(CommonConfig::getKeyName, "v_sion") + .one(); + Integer vsionStr = Integer.parseInt(vsion.getKeyContent()); + String trial = "release"; + if(vsionStr == 0){ + trial= "release"; + }else if(vsionStr == 1){ + trial= "trial"; + }else{ + trial= "develop"; + } + +// WxQrCodeVo o = (WxQrCodeVo)redisUtil.get("CodeImage::" + trial+ member.getId()); +// if(o!=null){ +// +// +// o.setName("瑶都万能墙欢迎您的加入"); +// return Result.OK(o); +// } + + Map param = new HashMap<>(); + + CommonConfig xcxSharePage = commonConfigService.lambdaQuery() + .eq(CommonConfig::getKeyName, "xcxSharePage") + .one(); + + + + + + String key = "shareId=" + member.getId(); + + param.put("path", xcxSharePage.getKeyContent() + "?" + key); //跳转页面 + String accessToken = this.getAccessToken(); + RestTemplate rest = new RestTemplate(); + InputStream inputStream = null; + OutputStream outputStream = null; + File file = null; + +// LambdaQueryWrapper configImg = new LambdaQueryWrapper<>(); +// configImg.eq(DbConf::getIsDel,0).eq(DbConf::getKeyValue,"codeImg"); +// DbConf oneImg = confService.getOne(configImg); + + CommonConfig oneImage = commonConfigService.lambdaQuery() + .eq(CommonConfig::getKeyName, "codeImg") + .one(); + + + + + String codeImg = oneImage.getKeyContent(); + try{ + String url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + accessToken; + param.put("scene", member.getId()); + param.put("width", 150); + param.put("auto_color", false); + param.put("env_version", trial); + Map line_color = new HashMap<>(); + line_color.put("r", 0); + line_color.put("g", 0); + line_color.put("b", 0); + param.put("line_color", line_color); + MultiValueMap headers = new LinkedMultiValueMap<>(); + org.springframework.http.HttpEntity requestEntity = new org.springframework.http.HttpEntity(JSON.toJSONString(param), headers); + ResponseEntity entity = rest.exchange(url, HttpMethod.POST, requestEntity, byte[].class, new Object[0]); + byte[] result = entity.getBody(); + + inputStream = new ByteArrayInputStream(result); + String tempSave = codeImg; + String filePath = tempSave; + + file = new File(filePath); + if (!file.exists()) { + file.createNewFile(); + } + outputStream = new FileOutputStream(file); + int len = 0; + byte[] buf = new byte[1024]; + while ((len = inputStream.read(buf, 0, 1024)) != -1) { + outputStream.write(buf, 0, len); + } + outputStream.flush(); + /** + * 将文件上传至阿里云 + */ + DiskFileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem item = factory.createItem("File", "text/plain", true, file.getName()); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + try { + FileInputStream fis = new FileInputStream(file); + OutputStream os = item.getOutputStream(); + while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + MultipartFile mf = new CommonsMultipartFile(item); + //返回图片下载地址 + WxQrCodeVo wxCodeVo = new WxQrCodeVo(); + wxCodeVo.setUrl(this.uploadAliYunOss(mf)); + + + + + wxCodeVo.setName("三只青蛙欢迎您"); + +// redisUtil.set("CodeImage::"+trial+member.getId(),wxCodeVo); + return Result.OK(wxCodeVo); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + //删除文件 + if (file.exists()) { + file.delete(); + } + } return null; } + + /** + * 获取令牌 + * + * @return + */ + private String getAccessToken() { + String requestUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret; + String doGet2 = HttpClientUtil.doGet2(requestUrl); + Map map = JSON.parseObject(doGet2, new TypeReference>() { + }); + return map.get("access_token"); + } + /** + * 上传文件至阿里云oss + * + * @return + */ + private String uploadAliYunOss(MultipartFile mf) throws Exception { + String uploadFile = "WxCodeFile"; + String fileName = new StringBuffer(mf.getOriginalFilename()).append(".jpg").toString();// 获取文件名 + String dbpath = uploadFile + File.separator + fileName; + if (dbpath.contains("\\")) { + dbpath = dbpath.replace("\\", "/"); + } + String endpoint = this.endpoint; + String accessKey = this.accessKey; + String secretKey = this.secretKey; + // 创建OSSClient实例。 + OSS ossClient = new OSSClientBuilder().build(endpoint, accessKey, secretKey); + // 上传Byte数组。 + byte[] content = mf.getBytes(); + String bucketName = this.bucketName; + ossClient.putObject(bucketName, dbpath, new ByteArrayInputStream(content)); + // 关闭OSSClient。 + ossClient.shutdown(); + return dbpath; + } + + + + + + + + + + //获取相关介绍 @Override public Result getInfoIntroduce(String type){ @@ -685,6 +1070,7 @@ public class ApiRiceServiceImpl implements ApiRiceService { @Override public Result addOrUpdateAddress(String token,CommonAddress commonAddress){ HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiOpenId(token); + commonAddress.setUserId(hanHaiMember.getId()); commonAddressService.saveOrUpdate(commonAddress); return Result.OK("增加成功"); } diff --git a/applet-rice-api/src/main/java/org/jeecg/bean/HttpClientUtil.java b/applet-rice-api/src/main/java/org/jeecg/bean/HttpClientUtil.java new file mode 100644 index 0000000..2307e06 --- /dev/null +++ b/applet-rice-api/src/main/java/org/jeecg/bean/HttpClientUtil.java @@ -0,0 +1,1122 @@ +package org.jeecg.bean; + + + + +import com.alibaba.fastjson.JSON; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.NameValuePair; +import org.apache.http.client.CookieStore; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.*; +import org.apache.http.client.utils.HttpClientUtils; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContextBuilder; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import javax.net.ssl.SSLContext; +import java.io.IOException; +import java.net.URI; +import java.nio.charset.Charset; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 通过url获取数据 + * + * @author zc + * + */ +public class HttpClientUtil { + + /** + * 设置可访问https + * @return + */ + public static CloseableHttpClient createSSLClientDefault() { + try { + SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { + //信任所有 + public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { + return true; + } + }).build(); + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + + return HttpClients.custom().setSSLSocketFactory(sslsf).build(); + } catch (KeyManagementException e) { + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (KeyStoreException e) { + e.printStackTrace(); + } + return HttpClients.createDefault(); + } +/*************************************Get**********************************************/ + /** + * 一般查询用doget + * @param url + * @param param + * @param + * @return + */ + public static String doGet(String url, Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpclient = createSSLClientDefault();//调用createSSLClientDefault + String resultString = ""; + CloseableHttpResponse response = null; + try { + + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + CookieStore cookieStore = new BasicCookieStore(); + httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); + //设置请求头 +// if (parameter != null) { +// //签名 +// httpGet.addHeader("Sign",parameter.getSign()); +// //用户ID +// httpGet.addHeader("User_ID",parameter.getUserId()+""); +// //用户角色ID +// httpGet.addHeader("User_RID",parameter.getRId()); +// //用户单位ID +// httpGet.addHeader("Dept_ID",parameter.getDeptId()+""); +// //用户科室ID +// httpGet.addHeader("Unit_ID",parameter.getUnitid()+""); +// httpGet.addHeader("CacheKey",parameter.getCacheKey()); +// httpGet.addHeader("Org_id", parameter.getOrg_id() + ""); +// httpGet.addHeader("Product_id", parameter.getProduct_id() + ""); +// httpGet.addHeader("Timestamp", parameter.getTimestamp()); +// } + + // 执行请求 + response = httpclient.execute(httpGet); + // 判断返回状态是否为200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), + "UTF-8"); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + public static String doGet(String url) { + return doGet(url, null); + } + + public static String doGet3(String url, Map param) { + // 创建Httpclient对象 + //调用createSSLClientDefault + CloseableHttpClient httpclient = createSSLClientDefault(); + String resultString = ""; + CloseableHttpResponse response = null; + try { + + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); + //设置请求头 +// if (parameter != null) { +// //签名 +// httpGet.addHeader("Sign",parameter.getSign()); +// //用户ID +// httpGet.addHeader("User_ID",parameter.getUserId()+""); +// //用户角色ID +// httpGet.addHeader("User_RID",parameter.getRId()); +// //用户单位ID +// httpGet.addHeader("Dept_ID",parameter.getDeptId()+""); +// //用户科室ID +// httpGet.addHeader("Unit_ID",parameter.getUnitid()+""); +// httpGet.addHeader("CacheKey",parameter.getCacheKey()); +// httpGet.addHeader("Org_id", parameter.getOrg_id() + ""); +// httpGet.addHeader("Product_id", parameter.getProduct_id() + ""); +// httpGet.addHeader("Timestamp", parameter.getTimestamp()); +// } + + // 执行请求 + response = httpclient.execute(httpGet); + // 判断返回状态是否为200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), + "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + /** + * 上传文件的doGet + * @param url + * @param param + * @param + * @return + */ + public static String doGet2(String url, Map param) { + + // 创建Httpclient对象 + CloseableHttpClient httpclient = createSSLClientDefault(); + String resultString = ""; + CloseableHttpResponse response = null; + try { + + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); +// if (parameter != null) { +// //用户ID +// httpGet.addHeader("User_ID",parameter.getUserId()+""); +// //用户角色ID +// httpGet.addHeader("User_RID",parameter.getRId()); +// //用户单位ID +// httpGet.addHeader("Dept_ID",parameter.getDeptId()+""); +// //用户科室ID +// httpGet.addHeader("Unit_ID",parameter.getUnitid()+""); +// httpGet.addHeader("CacheKey",parameter.getCacheKey()); +// httpGet.addHeader("Org_id", parameter.getOrg_id()); +// httpGet.addHeader("Product_id", parameter.getProduct_id()); +// httpGet.addHeader("Sign", parameter.getSign()); +// httpGet.addHeader("requestCode", parameter.getRequestCode()); +// httpGet.addHeader("Content-Type", "application/json;charset=UTF-8"); +// httpGet.addHeader("Timestamp", parameter.getTimestamp()); +// } + // 执行请求 + response = httpclient.execute(httpGet); + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), + "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + public static String doGet2(String url) { + return doGet2(url, null); + + } + + public static String doGet4(String url, Map param) { + // 创建Httpclient对象 + //调用createSSLClientDefault + CloseableHttpClient httpclient = createSSLClientDefault(); + String resultString = ""; + CloseableHttpResponse response = null; + try { + + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); + //设置请求头 +// httpGet.addHeader(""); +// if (parameter != null) { +// //签名 +// httpGet.addHeader("Sign",parameter.getSign()); +// //用户ID +// httpGet.addHeader("User_ID",parameter.getUserId()+""); +// //用户角色ID +// httpGet.addHeader("User_RID",parameter.getRId()); +// //用户单位ID +// httpGet.addHeader("Dept_ID",parameter.getDeptId()+""); +// //用户科室ID +// httpGet.addHeader("Unit_ID",parameter.getUnitid()+""); +// httpGet.addHeader("CacheKey",parameter.getCacheKey()); +// httpGet.addHeader("Org_id", parameter.getOrg_id() + ""); +// httpGet.addHeader("Product_id", parameter.getProduct_id() + ""); +// httpGet.addHeader("Timestamp", parameter.getTimestamp()); +// } + + // 执行请求 + response = httpclient.execute(httpGet); + // 判断返回状态是否为200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), + "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + public static String doGet5(String url, Map param) { + // 创建Httpclient对象 + //调用createSSLClientDefault + CloseableHttpClient httpclient = createSSLClientDefault(); + String resultString = ""; + CloseableHttpResponse response = null; + try { + + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + + // 创建http GET请求 + HttpGet httpGet = new HttpGet(uri); + //设置请求头 +// httpGet.addHeader(""); +// if (parameter != null) { +// httpGet.addHeader("Accept","application/json, text/javascript, */*; q=0.01"); +// httpGet.addHeader("Accept-Encoding","gzip, deflate, br"); +// httpGet.addHeader("Accept-Language","zh-CN,zh;q=0.9"); +// httpGet.addHeader("Connection","keep-alive"); + httpGet.addHeader("Cookie","PHPSESSID=b1epvn4gilmvlqd63gb71sgb4m"); +// httpGet.addHeader("Host","www.5577yc.com"); +// httpGet.addHeader("Referer","https://www.5577yc.com/pc/member/index.html"); +// httpGet.addHeader("Sec-Fetch-Mode","cors"); +// httpGet.addHeader("Sec-Fetch-Site","same-origin"); +// httpGet.addHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"); + httpGet.addHeader("X-Requested-With","XMLHttpRequest"); +// httpGet.addHeader("Org_id", parameter.getOrg_id() + ""); +// httpGet.addHeader("Product_id", parameter.getProduct_id() + ""); +// httpGet.addHeader("Timestamp", parameter.getTimestamp()); +// } + + // 执行请求 + response = httpclient.execute(httpGet); + // 判断返回状态是否为200 + if (response.getStatusLine().getStatusCode() == 200) { + resultString = EntityUtils.toString(response.getEntity(), + "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + public static String doGet5(String url) { + return doGet5(url, null); + + } + /*************************************Get**********************************************/ + + /*************************************Post**********************************************/ + /** + * 原始doPost 基本不用 + * @param url + * @param param + * @param + * @return + */ + public static String doPost(String url, Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity( + paramList); + httpPost.setEntity(entity); + } + // 执行http请求 + response = httpClient.execute(httpPost); + + + + + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return resultString; + } + + /** + * 项目经常用的doPost2 + * @param url + * @param param + * @param + * @return + */ + public static String doPost2(String url, Map param){ + + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(uri); + httpPost.setHeader("Content-type", "application/x-www-form-urlencoded"); +// httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity( + paramList,"UTF-8"); + entity.setContentEncoding("UTF-8"); + entity.setContentType("application/x-www-form-urlencoded"); + httpPost.setEntity(entity); + + } + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return resultString; + } + + /** + * .net登录post + * @param url + * @param param + * @param + * @return + */ + public static String doPost3(String url, Map param){ + + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(uri); + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity( + paramList, Charset.forName("UTF-8")); + entity.setContentEncoding("UTF-8"); + httpPost.setEntity(entity); + } + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return resultString; + } + + + + /** + * 微信文件上传 + * @param url + * @param content + * @param fileName + * @return + */ + public static String doPost6(String url, byte[] content,String fileName){ + + String resultString = null; + //创建HttpClient + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + org.apache.http.entity.mime.MultipartEntityBuilder builder = org.apache.http.entity.mime.MultipartEntityBuilder.create(); + /*绑定文件参数,传入文件流和contenttype,此处也可以继续添加其他formdata参数*/ + builder.addBinaryBody("file",content, ContentType.MULTIPART_FORM_DATA,fileName); + HttpEntity entity = builder.build(); + httpPost.setEntity(entity); + HttpResponse response = null; + //执行提交 + try{ + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + HttpClientUtils.closeQuietly(httpClient); + HttpClientUtils.closeQuietly(response); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return resultString; + } + + + /** + * 微信公众号文件上传 + * @param url + * @param content + * @param fileName + * @return + */ + public static String doPost7(String url, byte[] content,String fileName){ + + String resultString = null; + //创建HttpClient + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + org.apache.http.entity.mime.MultipartEntityBuilder builder = org.apache.http.entity.mime.MultipartEntityBuilder.create(); + /*绑定文件参数,传入文件流和contenttype,此处也可以继续添加其他formdata参数*/ + builder.addBinaryBody("media",content, ContentType.MULTIPART_FORM_DATA,fileName); + HttpEntity entity = builder.build(); + httpPost.setEntity(entity); + HttpResponse response = null; + //执行提交 + try{ + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + HttpClientUtils.closeQuietly(httpClient); + HttpClientUtils.closeQuietly(response); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return resultString; + } + + /** + * 项目经常用的doPost4 + * @param url + * @param param + * @return + */ + public static String doPost4(String url, Map param){ + + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + StringBuffer cookie = new StringBuffer(); + Map map = new HashMap<>(); + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(uri); + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + httpPost.addHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity( + paramList, Charset.forName("UTF-8")); + httpPost.setEntity(entity); + } + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return resultString; + } + + + /** + * 项目经常用的doPost4 + * @param url + * @param param + * @param parameter + * @return + */ + public static String doPost5(String url, Map param,String parameter){ + + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + StringBuffer cookie = new StringBuffer(); + Map map = new HashMap<>(); + try { + // 创建uri + CookieStore cookieStore = new BasicCookieStore(); + httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(uri); + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + httpPost.addHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); + httpPost.addHeader("Host","www.www7945.com"); + httpPost.addHeader("Origin","https://www.www7945.com"); + httpPost.addHeader("Referer","https://www.www7945.com/mobile/"); + httpPost.addHeader("User-Agent:","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"); + httpPost.addHeader("Connection","keep-alive"); + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity( + paramList, Charset.forName("UTF-8")); + entity.setContentEncoding("UTF-8"); + httpPost.setEntity(entity); + } + if(parameter!=null){ + httpPost.addHeader("Cookie",parameter); + } + // 执行http请求 + response = httpClient.execute(httpPost); + String tokenStr = null; + + if (response != null) { + int statusCode = response.getStatusLine().getStatusCode(); + if (statusCode == HttpStatus.SC_OK) { + // 获得Cookies + List cookies = cookieStore.getCookies(); + for (org.apache.http.cookie.Cookie c : cookies) { + cookie.append(c.getName()).append("=").append(c.getValue()).append(";"); + if (c.getName().contains("token")) { + tokenStr = c.getValue(); + } + } + } + } + map.put("token",tokenStr); + map.put("cookie",cookie.toString()); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + map.put("resultString",JSON.parse(resultString)); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(parameter!=null){ + return resultString; + } + return JSON.toJSONString(map); + } + + + + public static String doPost5(String url) { + return doPost5(url, null,null); + } + + public static String doPost4(String url) { + return doPost4(url, null); + } + + public static String doPost2(String url) { + return doPost2(url); + } + + + public static String doPost(String url) { + return doPost(url, null); + } + + /** + * 当数据需要以JSON格式传输 + * @param url + * @param json + * @param + * @return + */ + public static String doPostJson(String url, String json) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + // 创建请求内容 + StringEntity entity = new StringEntity(json, + ContentType.APPLICATION_JSON); + httpPost.setEntity(entity); + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return resultString; + } + + + public static String doPostJson3(String url, String json) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + // 创建请求内容 + StringEntity entity = new StringEntity(json, + ContentType.APPLICATION_FORM_URLENCODED); + httpPost.setEntity(entity); + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return resultString; + } + + /** + * 文件上传 + * @param url + * @param json + * @param + * @return + */ + public static String doPostJson2(String url, String json) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPost httpPost = new HttpPost(url); + // 创建请求内容 + StringEntity entity = new StringEntity(json, + ContentType.APPLICATION_JSON); + httpPost.setEntity(entity); + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return resultString; + } + + /*************************************Post**********************************************/ + + + + + + + + + /*************************************Delete**********************************************/ + /** + * 原始删除 基本不怎么用 + * @param url + * @return + */ + public static String doDelete(String url) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + + try { + // 创建Http Post请求 + HttpDelete httpPost = new HttpDelete(url); + // 执行http请求 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + /** + * 常用删除 + * @param url + * @param param + * @param + * @return + */ + public static String doDelete2(String url,Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建Http Delete请求 + HttpDelete httpDelete = new HttpDelete(uri); + // 执行http请求 + response = httpClient.execute(httpDelete); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + /** + * 上传文件删除 + * @param url + * @param param + * @param + * @return + */ + public static String doDelete3(String url,Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建Http Delete请求 + HttpDelete httpDelete = new HttpDelete(uri); + // 执行http请求 + response = httpClient.execute(httpDelete); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return resultString; + } + + /*************************************Delete**********************************************/ + + + + + + + + + + /*************************************Put**********************************************/ + public static String doPut(String url) { + return doPut(url, null); + } + + /** + * 修改 + * @param url + * @param param + * @param + * @return + */ + public static String doPut(String url, Map param) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + + try { + // 创建uri + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + // 创建Http Put请求 + HttpPut httpPut = new HttpPut(uri); + // 创建参数列表 + if (param != null) { + List paramList = new ArrayList<>(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // 模拟表单 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity( + paramList, Charset.forName("UTF-8"));//Charset.forName("UTF-8")解决乱码 + entity.setContentEncoding("UTF-8"); + httpPut.setEntity(entity); + } + // 执行http请求 + response = httpClient.execute(httpPut); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return resultString; + } + + /** + * 以JSON格式修改 + * @param url + * @param json + * @param parameter + * @return + */ + public static String doPutJson(String url, String json) { + // 创建Httpclient对象 + CloseableHttpClient httpClient = createSSLClientDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 创建Http Post请求 + HttpPut httpPut = new HttpPut(url); + // 创建请求内容 + StringEntity entity = new StringEntity(json, + ContentType.APPLICATION_JSON); + httpPut.setEntity(entity); + // 执行http请求 + response = httpClient.execute(httpPut); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + return resultString; + } + + + +} + diff --git a/applet-rice-api/src/main/java/org/jeecg/bean/WxQrCodeVo.java b/applet-rice-api/src/main/java/org/jeecg/bean/WxQrCodeVo.java new file mode 100644 index 0000000..6a6249c --- /dev/null +++ b/applet-rice-api/src/main/java/org/jeecg/bean/WxQrCodeVo.java @@ -0,0 +1,14 @@ +package org.jeecg.bean; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class WxQrCodeVo { + /**图片地址*/ + @ApiModelProperty(value = "图片地址") + private String url; + + @ApiModelProperty(value = "加油站名称") + private String name; +} diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/controller/CommonOrderController.java b/module-common/src/main/java/org/jeecg/modules/commonOrder/controller/CommonOrderController.java index ff0b4c5..a76ca0d 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/controller/CommonOrderController.java +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/controller/CommonOrderController.java @@ -39,7 +39,7 @@ import org.jeecg.common.aspect.annotation.AutoLog; /** * @Description: 订单信息表 * @Author: jeecg-boot - * @Date: 2024-12-05 + * @Date: 2024-12-06 * @Version: V1.0 */ @Api(tags="订单信息表") diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/entity/CommonOrder.java b/module-common/src/main/java/org/jeecg/modules/commonOrder/entity/CommonOrder.java index 5724eef..eedc8f3 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/entity/CommonOrder.java +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/entity/CommonOrder.java @@ -24,7 +24,7 @@ import lombok.experimental.Accessors; /** * @Description: 订单信息表 * @Author: jeecg-boot - * @Date: 2024-12-05 + * @Date: 2024-12-06 * @Version: V1.0 */ @Data @@ -107,6 +107,11 @@ public class CommonOrder implements Serializable { @Excel(name = "支付编号", width = 15) @ApiModelProperty(value = "支付编号") private java.lang.String payNo; + /**商品类型*/ + @Excel(name = "商品类型", width = 15, dicCode = "shop_type") + @Dict(dicCode = "shop_type") + @ApiModelProperty(value = "商品类型") + private java.lang.Integer shopState; @TableField(exist = false) diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/mapper/CommonOrderMapper.java b/module-common/src/main/java/org/jeecg/modules/commonOrder/mapper/CommonOrderMapper.java index 5ca8f76..d8e7882 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/mapper/CommonOrderMapper.java +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/mapper/CommonOrderMapper.java @@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; /** * @Description: 订单信息表 * @Author: jeecg-boot - * @Date: 2024-12-05 + * @Date: 2024-12-06 * @Version: V1.0 */ public interface CommonOrderMapper extends BaseMapper { diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/service/ICommonOrderService.java b/module-common/src/main/java/org/jeecg/modules/commonOrder/service/ICommonOrderService.java index ba56cdc..f656d2b 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/service/ICommonOrderService.java +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/service/ICommonOrderService.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; /** * @Description: 订单信息表 * @Author: jeecg-boot - * @Date: 2024-12-05 + * @Date: 2024-12-06 * @Version: V1.0 */ public interface ICommonOrderService extends IService { diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/service/impl/CommonOrderServiceImpl.java b/module-common/src/main/java/org/jeecg/modules/commonOrder/service/impl/CommonOrderServiceImpl.java index 63d93f5..95c4703 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/service/impl/CommonOrderServiceImpl.java +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/service/impl/CommonOrderServiceImpl.java @@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; /** * @Description: 订单信息表 * @Author: jeecg-boot - * @Date: 2024-12-05 + * @Date: 2024-12-06 * @Version: V1.0 */ @Service diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/CommonOrderList.vue b/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/CommonOrderList.vue index e3144f6..7be57a6 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/CommonOrderList.vue +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/CommonOrderList.vue @@ -4,6 +4,21 @@
+ + + + + + + + 查询 + 重置 + + {{ toggleSearchStatus ? '收起' : '展开' }} + + + +
@@ -99,6 +114,7 @@ import { mixinDevice } from '@/utils/mixin' import { JeecgListMixin } from '@/mixins/JeecgListMixin' import CommonOrderModal from './modules/CommonOrderModal' + import {filterMultiDictText} from '@/components/dict/JDictSelectUtil' export default { name: 'CommonOrderList', @@ -191,6 +207,11 @@ align:"center", dataIndex: 'payNo' }, + { + title:'商品类型', + align:"center", + dataIndex: 'shopState_dictText' + }, { title: '操作', dataIndex: 'action', @@ -239,6 +260,7 @@ fieldList.push({type:'string',value:'addressId',text:'地址标识',dictCode:''}) fieldList.push({type:'string',value:'shopId',text:'商品标识',dictCode:''}) fieldList.push({type:'string',value:'payNo',text:'支付编号',dictCode:''}) + fieldList.push({type:'string',value:'shopState',text:'商品类型',dictCode:'shop_type'}) this.superFieldList = fieldList } } diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/modules/CommonOrderForm.vue b/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/modules/CommonOrderForm.vue index 9eb34ab..563988f 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/modules/CommonOrderForm.vue +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/vue/modules/CommonOrderForm.vue @@ -73,6 +73,11 @@ + + + + + diff --git a/module-common/src/main/java/org/jeecg/modules/commonOrder/vue3/CommonOrder.data.ts b/module-common/src/main/java/org/jeecg/modules/commonOrder/vue3/CommonOrder.data.ts index 2ece5b0..317f512 100644 --- a/module-common/src/main/java/org/jeecg/modules/commonOrder/vue3/CommonOrder.data.ts +++ b/module-common/src/main/java/org/jeecg/modules/commonOrder/vue3/CommonOrder.data.ts @@ -74,9 +74,23 @@ export const columns: BasicColumn[] = [ align:"center", dataIndex: 'payNo' }, + { + title: '商品类型', + align:"center", + dataIndex: 'shopState_dictText' + }, ]; //查询数据 export const searchFormSchema: FormSchema[] = [ + { + label: "商品类型", + field: "shopState", + component: 'JDictSelectTag', + componentProps:{ + dictCode:"shop_type" + }, + colProps: {span: 6}, + }, ]; //表单数据 export const formSchema: FormSchema[] = [ @@ -150,4 +164,12 @@ export const formSchema: FormSchema[] = [ field: 'payNo', component: 'Input', }, + { + label: '商品类型', + field: 'shopState', + component: 'JDictSelectTag', + componentProps:{ + dictCode:"shop_type" + }, + }, ]; diff --git a/module-system/module-system.iml b/module-system/module-system.iml index d7358c7..f8b8e24 100644 --- a/module-system/module-system.iml +++ b/module-system/module-system.iml @@ -259,7 +259,6 @@ - @@ -300,6 +299,7 @@ + diff --git a/module-system/src/main/resources/application-dev.yml b/module-system/src/main/resources/application-dev.yml index 65bf432..cdc2bb2 100644 --- a/module-system/src/main/resources/application-dev.yml +++ b/module-system/src/main/resources/application-dev.yml @@ -1,5 +1,5 @@ server: - port: 8001 + port: 8000 tomcat: max-swallow-size: -1 error: diff --git a/module-system/src/main/resources/pay_weixin.properties b/module-system/src/main/resources/pay_weixin.properties index 6d5c2b9..d3c34a5 100644 --- a/module-system/src/main/resources/pay_weixin.properties +++ b/module-system/src/main/resources/pay_weixin.properties @@ -2,7 +2,7 @@ pay.mchId=1700534180 pay.appId=wx0839bc52e7849c13 pay.mchKey=9bde2770a74c2a460592de2d451ce05f pay.keyPath=classpath:apiclient_cert.pem -pay.notifyUrl=http://h5.xzaiyp.top/rice-admin/rice_index/payNotify -pay.notifyUrlDev=http://h5.xzaiyp.top/rice-admin/rice_index/payNotify +pay.notifyUrl=https://admin.szqwdgidm.com/rice-admin/rice_index/payNotify +pay.notifyUrlDev=https://admin.szqwdgidm.com/rice-admin/rice_index/payNotify