From 7198cf3332bb9d725e35ec153a98719099883b3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com>
Date: Fri, 16 Aug 2024 04:32:36 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=80=E7=A5=A8=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 7 +
.../controller/ThinkInvoiceController.java | 151 +++++++++++++++++-
.../com/gxwebsoft/think/entity/NuoNuo.java | 26 +++
.../gxwebsoft/think/entity/NuoNuoGoods.java | 71 ++++++++
.../gxwebsoft/think/entity/NuoNuoOrder.java | 90 +++++++++++
.../gxwebsoft/think/entity/NuoNuoResult.java | 34 ++++
.../think/entity/NuoNuoResultNo.java | 26 +++
.../gxwebsoft/think/entity/ThinkInvoice.java | 4 +-
.../gxwebsoft/think/entity/ThinkOrder.java | 1 +
.../think/mapper/xml/ThinkOrderMapper.xml | 2 +-
.../mapper/xml/ThinkRechargeLogMapper.xml | 16 +-
.../impl/ThinkRechargeLogServiceImpl.java | 26 ++-
src/test/java/com/gxwebsoft/TestMain.java | 4 +-
13 files changed, 442 insertions(+), 16 deletions(-)
create mode 100644 src/main/java/com/gxwebsoft/think/entity/NuoNuo.java
create mode 100644 src/main/java/com/gxwebsoft/think/entity/NuoNuoGoods.java
create mode 100644 src/main/java/com/gxwebsoft/think/entity/NuoNuoOrder.java
create mode 100644 src/main/java/com/gxwebsoft/think/entity/NuoNuoResult.java
create mode 100644 src/main/java/com/gxwebsoft/think/entity/NuoNuoResultNo.java
diff --git a/pom.xml b/pom.xml
index da13efd..78e9c36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -272,6 +272,13 @@
3.17.0
+
+
+ com.nuonuo
+ open-sdk
+ 1.0.5.2
+
+
com.aliyun
diff --git a/src/main/java/com/gxwebsoft/think/controller/ThinkInvoiceController.java b/src/main/java/com/gxwebsoft/think/controller/ThinkInvoiceController.java
index dfc8bd9..a900c49 100644
--- a/src/main/java/com/gxwebsoft/think/controller/ThinkInvoiceController.java
+++ b/src/main/java/com/gxwebsoft/think/controller/ThinkInvoiceController.java
@@ -1,22 +1,32 @@
package com.gxwebsoft.think.controller;
-import com.gxwebsoft.common.core.web.BaseController;
-import com.gxwebsoft.think.service.ThinkInvoiceService;
-import com.gxwebsoft.think.entity.ThinkInvoice;
-import com.gxwebsoft.think.param.ThinkInvoiceParam;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.gxwebsoft.common.core.utils.JSONUtil;
import com.gxwebsoft.common.core.web.ApiResult;
-import com.gxwebsoft.common.core.web.PageResult;
-import com.gxwebsoft.common.core.web.PageParam;
+import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
-import com.gxwebsoft.common.core.annotation.OperationLog;
-import com.gxwebsoft.common.system.entity.User;
+import com.gxwebsoft.common.core.web.PageResult;
+import com.gxwebsoft.think.entity.*;
+import com.gxwebsoft.think.param.ThinkInvoiceParam;
+import com.gxwebsoft.think.service.ThinkInvoiceService;
+import com.gxwebsoft.think.service.ThinkOrderInfoService;
+import com.gxwebsoft.think.service.ThinkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
+import nuonuo.open.sdk.NNOpenSDK;
import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.HashMap;
import java.util.List;
+import java.util.UUID;
/**
* 控制器
@@ -30,6 +40,10 @@ import java.util.List;
public class ThinkInvoiceController extends BaseController {
@Resource
private ThinkInvoiceService thinkInvoiceService;
+ @Resource
+ private ThinkOrderService thinkOrderService;
+ @Resource
+ private ThinkOrderInfoService thinkOrderInfoService;
@ApiOperation("分页查询")
@GetMapping("/page")
@@ -107,4 +121,125 @@ public class ThinkInvoiceController extends BaseController {
return fail("删除失败");
}
+
+ @ApiOperation("开具发票")
+ @PostMapping("/doInvoice")
+ public ApiResult> doInvoice(@RequestBody ThinkInvoice thinkInvoice) {
+ System.out.println("thinkInvoice = " + thinkInvoice);
+ final Integer oid = thinkInvoice.getOid();
+ final ThinkOrder thinkOrder = thinkOrderService.getById(thinkInvoice.getOid());
+ System.out.println("thinkOrder = " + thinkOrder);
+ final List orderInfos = thinkOrderInfoService.list(new LambdaQueryWrapper().eq(ThinkOrderInfo::getOid,thinkInvoice.getOid()));
+
+ // 开票接口
+ NNOpenSDK sdk = NNOpenSDK.getIntance();
+ String taxnum = "339901999999142";//ISV下授权商户税号,自用型应用置""即可
+ String appKey = "SD56531018";
+ String appSecret = "SD3C429B318C485E";
+ String method = "nuonuo.OpeMplatform.requestBillingNew";//API方法名
+ String token = NNOpenSDK.getIntance().getMerchantToken("SD56531018", "SD3C429B318C485E"); //访问令牌
+ final NuoNuo nuoNuo = new NuoNuo();
+ final NuoNuoOrder order = new NuoNuoOrder();
+ order.setBuyerName(thinkInvoice.getName());
+ order.setBuyerTaxNum(thinkInvoice.getCode());
+// order.setBuyerPhone(thinkInvoice.getPhone());
+// order.setSalerTaxNum(invoice.getInvoiceCode());
+// order.setSalerTel(invoice.getPhone());
+ order.setSalerTaxNum("339901999999142"); // 91450100737617400R
+ order.setSalerTel("339901999999142");
+ order.setOrderNo(thinkOrder.getOrderNum());
+ order.setInvoiceDate(DateUtil.now());
+ order.setClerk("赵裕璐");
+ order.setPayee("班嘉良");
+ order.setChecker("蓝蕙孚");
+ order.setBuyerPhone(thinkInvoice.getPhone());
+ order.setInvoiceType(String.valueOf(thinkInvoice.getInvoicetype()));
+ order.setRemark("不动产地址:广西壮族自治区南宁市良庆区五象大道西段669号广西体育中心综合馆;(市)标志:否;");
+ final NuoNuoGoods goods = new NuoNuoGoods();
+ goods.setGoodsName("场地费");
+ goods.setGoodsCode("3040502029902000000");
+ goods.setWithTaxFlag("0");
+ if (!CollectionUtils.isEmpty(orderInfos)) {
+ final ThinkOrderInfo thinkOrderInfo = orderInfos.get(0);
+ if (thinkOrderInfo != null) {
+ goods.setDField1(thinkOrderInfo.getDateTime());
+ }
+ }
+ goods.setDField2("无");
+ goods.setDField3("无");
+ goods.setDField4("无");
+ goods.setDField5("无");
+ goods.setTaxRate(new BigDecimal("0.05").toString());
+ final BigDecimal taxExcludedAmount = thinkOrder.getTotalPrice().divide(new BigDecimal("1.05"), 4, RoundingMode.HALF_UP);
+ final BigDecimal tax = taxExcludedAmount.multiply(new BigDecimal("0.05")).setScale(4,RoundingMode.HALF_EVEN);
+ goods.setTax(tax.toString());
+ goods.setTaxExcludedAmount(taxExcludedAmount.toString());
+ goods.setTaxIncludedAmount(thinkOrder.getTotalPrice().toString());
+ order.setInvoiceDetail(goods);
+ System.out.println("税额 = " + tax);
+ System.out.println("不含税金额 = " + taxExcludedAmount);
+ System.out.println("含税金额 = " + thinkOrder.getTotalPrice());
+ nuoNuo.setOrder(order);
+
+ String content = JSONUtil.toJSONString(nuoNuo);//API私有请求参数
+ String url = "https://sandbox.nuonuocs.cn/open/v1/services"; //SDK请求地址
+ String senid = UUID.randomUUID().toString(); // 唯一标识,由企业自己生成32位随机码
+ String json = sdk.sendPostSyncRequest(url, senid, appKey, appSecret, token, taxnum, method, content); // 请求API
+ System.out.println("json = " + json);
+ if (StrUtil.isNotBlank(json)) {
+ final JSONObject jsonObject = JSONObject.parseObject(json);
+ final String code = jsonObject.getString("code");
+ final String result = jsonObject.getString("result");
+ System.out.println("jsonObject = " + jsonObject);
+ if (code.equals("E0000")) {
+ final JSONObject resNo = JSONObject.parseObject(result);
+ final String invoiceSerialNum = resNo.getString("invoiceSerialNum");
+ thinkOrder.setIsInvoice(1);
+ thinkOrderService.updateById(thinkOrder);
+ System.out.println("invoiceSerialNum = " + invoiceSerialNum);
+ thinkInvoice.setId(null);
+ thinkInvoice.setIncoiveNum(invoiceSerialNum);
+ thinkInvoice.setIncoiveCode("339901999999142");
+ thinkInvoice.setUid(thinkOrder.getUid());
+ thinkInvoice.setCreateTime(System.currentTimeMillis()/1000);
+ thinkInvoiceService.save(thinkInvoice);
+ return success("发票开具成功", json);
+ }
+ }
+ return fail("发票开具失败");
+ }
+
+ @ApiOperation("根据id查询发票")
+ @GetMapping("/showInvoice/{orderId}")
+ public ApiResult> showInvoice(@PathVariable("orderId") Integer orderId) {
+ final ThinkInvoice thinkInvoice = thinkInvoiceService.getOne(new LambdaQueryWrapper().eq(ThinkInvoice::getOid,orderId));
+ System.out.println("thinkInvoice = " + thinkInvoice);
+ NNOpenSDK sdk = NNOpenSDK.getIntance();
+ String taxnum = "339901999999142";//ISV下授权商户税号,自用型应用置""即可
+ String appKey = "SD56531018";
+ String appSecret = "SD3C429B318C485E";
+ String method = "nuonuo.OpeMplatform.queryInvoiceResult";//API方法名
+ String token = NNOpenSDK.getIntance().getMerchantToken("SD56531018", "SD3C429B318C485E"); //访问令牌
+
+ HashMap map = new HashMap<>();
+// map.put("invoiceCode",invoiceNo);
+ map.put("serialNos", thinkInvoice.getIncoiveNum());
+// map.put("inTaxAmount", order.getPayPrice().subtract(order.getPayPrice().multiply(new BigDecimal("0.06")))); // 含税金额
+// map.put("exTaxAmount", order.getPayPrice()); // 不含税金额
+ System.out.println("map = " + map);
+ String content = JSONUtil.toJSONString(map);//API私有请求参数
+ String url = "https://sandbox.nuonuocs.cn/open/v1/services"; //SDK请求地址
+ String senid = UUID.randomUUID().toString(); // 唯一标识,由企业自己生成32位随机码
+
+ String result = sdk.sendPostSyncRequest(url, senid, appKey, appSecret, token, taxnum, method, content);
+ System.out.println("result = " + result);
+ final JSONObject jsonObject = JSONObject.parseObject(result);
+ final String code = jsonObject.getString("code");
+ final String body = jsonObject.getString("result");
+ if (code.equals("E0000")) {
+ return success("查询成功", body);
+ }
+ return success("查询失败", result);
+ }
+
}
diff --git a/src/main/java/com/gxwebsoft/think/entity/NuoNuo.java b/src/main/java/com/gxwebsoft/think/entity/NuoNuo.java
new file mode 100644
index 0000000..a94fa2e
--- /dev/null
+++ b/src/main/java/com/gxwebsoft/think/entity/NuoNuo.java
@@ -0,0 +1,26 @@
+package com.gxwebsoft.think.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 发票
+ *
+ * @author 科技小王子
+ * @since 2024-05-25 17:20:15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "NuoNuo开票对象", description = "开票对象")
+public class NuoNuo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "订单信息")
+ @TableField(exist = false)
+ private NuoNuoOrder order;
+}
diff --git a/src/main/java/com/gxwebsoft/think/entity/NuoNuoGoods.java b/src/main/java/com/gxwebsoft/think/entity/NuoNuoGoods.java
new file mode 100644
index 0000000..8a372ca
--- /dev/null
+++ b/src/main/java/com/gxwebsoft/think/entity/NuoNuoGoods.java
@@ -0,0 +1,71 @@
+package com.gxwebsoft.think.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 发票
+ *
+ * @author 科技小王子
+ * @since 2024-05-25 17:20:15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "NuoNuo开票对象", description = "开票对象")
+public class NuoNuoGoods implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "商品名称")
+ @TableField(exist = false)
+ private String goodsName;
+
+ @ApiModelProperty(value = "服务分类")
+ @TableField(exist = false)
+ private String goodsCode;
+
+ @ApiModelProperty(value = "单价含税标志:0:不含税,1:含税")
+ @TableField(exist = false)
+ private String withTaxFlag;
+
+ @ApiModelProperty(value = "税额")
+ @TableField(exist = false)
+ private String tax;
+
+ @ApiModelProperty(value = "税率,注:1、纸票清单红票存在为null的情况;2、二手车发票税率为null或者0")
+ @TableField(exist = false)
+ private String taxRate;
+
+ @ApiModelProperty(value = "不含税金额")
+ @TableField(exist = false)
+ private String taxExcludedAmount;
+
+ @ApiModelProperty(value = "含税金额")
+ @TableField(exist = false)
+ private String taxIncludedAmount;
+
+ @ApiModelProperty(value = "业务方明细自定义字段1,本应用只作保存")
+ @TableField(exist = false)
+ private String dField1;
+
+ @ApiModelProperty(value = "业务方明细自定义字段1,本应用只作保存")
+ @TableField(exist = false)
+ private String dField2;
+
+ @ApiModelProperty(value = "业务方明细自定义字段1,本应用只作保存")
+ @TableField(exist = false)
+ private String dField3;
+
+ @ApiModelProperty(value = "业务方明细自定义字段1,本应用只作保存")
+ @TableField(exist = false)
+ private String dField4;
+
+ @ApiModelProperty(value = "业务方明细自定义字段1,本应用只作保存")
+ @TableField(exist = false)
+ private String dField5;
+
+}
diff --git a/src/main/java/com/gxwebsoft/think/entity/NuoNuoOrder.java b/src/main/java/com/gxwebsoft/think/entity/NuoNuoOrder.java
new file mode 100644
index 0000000..059dff6
--- /dev/null
+++ b/src/main/java/com/gxwebsoft/think/entity/NuoNuoOrder.java
@@ -0,0 +1,90 @@
+package com.gxwebsoft.think.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 发票
+ *
+ * @author 科技小王子
+ * @since 2024-05-25 17:20:15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "NuoNuo开票对象", description = "开票对象")
+@TableName("booking_user_invoice")
+public class NuoNuoOrder implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "购方名称")
+ @TableField(exist = false)
+ private String buyerName;
+
+ @ApiModelProperty(value = "购方税号")
+ @TableField(exist = false)
+ private String buyerTaxNum;
+
+ @ApiModelProperty(value = "销方税号号(使用沙箱环境请求时消息体参数salerTaxNum和消息头参数userTax填写339902999999789113)")
+ @TableField(exist = false)
+ private String salerTaxNum;
+
+ @ApiModelProperty(value = "销方电话")
+ @TableField(exist = false)
+ private String salerTel;
+
+ @ApiModelProperty(value = "销方地址")
+ @TableField(exist = false)
+ private String salerAddress;
+
+ @ApiModelProperty(value = "订单编号")
+ @TableField(exist = false)
+ private String orderNo;
+
+ @ApiModelProperty(value = "订单时间")
+ @TableField(exist = false)
+ private String invoiceDate;
+
+ @ApiModelProperty(value = "开票员")
+ @TableField(exist = false)
+ private String clerk;
+
+ @ApiModelProperty(value = "收款人")
+ @TableField(exist = false)
+ private String payee;
+
+ @ApiModelProperty(value = "复核人")
+ @TableField(exist = false)
+ private String checker;
+
+ @ApiModelProperty(value = "备注信息")
+ @TableField(exist = false)
+ private String remark;
+
+ @ApiModelProperty(value = "购方手机号")
+ @TableField(exist = false)
+ private String buyerPhone;
+
+ @ApiModelProperty(value = "推送邮箱")
+ @TableField(exist = false)
+ private String email;
+
+ @ApiModelProperty(value = "开票类型:1:蓝票;2:红票 (数电票冲红请对接数电快捷冲红接口)")
+ @TableField(exist = false)
+ private String invoiceType;
+
+ @ApiModelProperty(value = "开票明细")
+ @TableField(exist = false)
+ private NuoNuoGoods invoiceDetail;
+
+
+ @ApiModelProperty(value = "完整字段名invoiceTractorAndCombineHarvester,开具拖拉机和联合收割机特定要素的数电票才需要传specificFactor =13)")
+ @TableField(exist = false)
+ private String invoiceTractorAndCombineH;
+
+}
diff --git a/src/main/java/com/gxwebsoft/think/entity/NuoNuoResult.java b/src/main/java/com/gxwebsoft/think/entity/NuoNuoResult.java
new file mode 100644
index 0000000..45603de
--- /dev/null
+++ b/src/main/java/com/gxwebsoft/think/entity/NuoNuoResult.java
@@ -0,0 +1,34 @@
+package com.gxwebsoft.think.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 发票
+ *
+ * @author 科技小王子
+ * @since 2024-05-25 17:20:15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "NuoNuo开票对象", description = "开票对象")
+public class NuoNuoResult implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "编码")
+ @TableField(exist = false)
+ private String code;
+
+ @ApiModelProperty(value = "描述")
+ @TableField(exist = false)
+ private String describe;
+
+ @ApiModelProperty(value = "返回结果")
+ @TableField(exist = false)
+ private String result;
+}
diff --git a/src/main/java/com/gxwebsoft/think/entity/NuoNuoResultNo.java b/src/main/java/com/gxwebsoft/think/entity/NuoNuoResultNo.java
new file mode 100644
index 0000000..3615e24
--- /dev/null
+++ b/src/main/java/com/gxwebsoft/think/entity/NuoNuoResultNo.java
@@ -0,0 +1,26 @@
+package com.gxwebsoft.think.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * 发票
+ *
+ * @author 科技小王子
+ * @since 2024-05-25 17:20:15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "NuoNuo开票对象", description = "开票对象")
+public class NuoNuoResultNo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "发票流水号")
+ @TableField(exist = false)
+ private String invoiceSerialNum;
+}
diff --git a/src/main/java/com/gxwebsoft/think/entity/ThinkInvoice.java b/src/main/java/com/gxwebsoft/think/entity/ThinkInvoice.java
index d7bb44a..47a0fe5 100644
--- a/src/main/java/com/gxwebsoft/think/entity/ThinkInvoice.java
+++ b/src/main/java/com/gxwebsoft/think/entity/ThinkInvoice.java
@@ -80,9 +80,9 @@ public class ThinkInvoice implements Serializable {
@ApiModelProperty(value = "发票类型:1场地发票,2vip卡发票,3ic卡发票")
private Integer itype;
- private Integer createTime;
+ private Long createTime;
- private Integer updateTime;
+ private Long updateTime;
@ApiModelProperty(value = "1.普票,2是专票")
@TableField("InvoiceType")
diff --git a/src/main/java/com/gxwebsoft/think/entity/ThinkOrder.java b/src/main/java/com/gxwebsoft/think/entity/ThinkOrder.java
index 8a4af18..f660085 100644
--- a/src/main/java/com/gxwebsoft/think/entity/ThinkOrder.java
+++ b/src/main/java/com/gxwebsoft/think/entity/ThinkOrder.java
@@ -103,6 +103,7 @@ public class ThinkOrder implements Serializable {
private String qrcode;
@ApiModelProperty(value = "优惠说明")
+ @TableField("`desc`")
private String desc;
@ApiModelProperty(value = "vip月卡年卡、ic月卡年卡回退次数")
diff --git a/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkOrderMapper.xml b/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkOrderMapper.xml
index 00782a1..85c9654 100644
--- a/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkOrderMapper.xml
+++ b/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkOrderMapper.xml
@@ -126,7 +126,7 @@
AND a.check_bill = #{param.checkBill}
- AND (a.name LIKE CONCAT('%', #{param.keywords}, '%')
+ AND (a.name = #{param.keywords}
OR a.id = #{param.keywords}
OR a.order_num = #{param.keywords}
OR a.phone = #{param.keywords}
diff --git a/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkRechargeLogMapper.xml b/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkRechargeLogMapper.xml
index 36ec9d6..8aebe86 100644
--- a/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkRechargeLogMapper.xml
+++ b/src/main/java/com/gxwebsoft/think/mapper/xml/ThinkRechargeLogMapper.xml
@@ -33,6 +33,12 @@
AND a.create_time <= #{param.createTimeEnd}
+
+ AND a.create_time >= #{param.timeStart}
+
+
+ AND a.create_time <= #{param.timeEnd}
+
AND a.vid = #{param.vid}
@@ -43,9 +49,13 @@
AND a.check_bill = #{param.checkBill}
- AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
- )
-
+ AND (a.wechat_order = #{param.keywords}
+ OR a.order_num = #{param.keywords}
+ OR b.phone = #{param.keywords}
+ OR b.truename = #{param.keywords}
+ OR a.vid = #{param.keywords}
+ )
+
diff --git a/src/main/java/com/gxwebsoft/think/service/impl/ThinkRechargeLogServiceImpl.java b/src/main/java/com/gxwebsoft/think/service/impl/ThinkRechargeLogServiceImpl.java
index a19dc0a..36f469b 100644
--- a/src/main/java/com/gxwebsoft/think/service/impl/ThinkRechargeLogServiceImpl.java
+++ b/src/main/java/com/gxwebsoft/think/service/impl/ThinkRechargeLogServiceImpl.java
@@ -1,15 +1,23 @@
package com.gxwebsoft.think.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gxwebsoft.think.entity.ThinkSite;
import com.gxwebsoft.think.mapper.ThinkRechargeLogMapper;
import com.gxwebsoft.think.service.ThinkRechargeLogService;
import com.gxwebsoft.think.entity.ThinkRechargeLog;
import com.gxwebsoft.think.param.ThinkRechargeLogParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
+import com.gxwebsoft.think.service.ThinkSiteService;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import javax.annotation.Resource;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* Service实现
@@ -19,12 +27,28 @@ import java.util.List;
*/
@Service
public class ThinkRechargeLogServiceImpl extends ServiceImpl implements ThinkRechargeLogService {
-
+ @Resource
+ private ThinkSiteService thinkSiteService;
@Override
public PageResult pageRel(ThinkRechargeLogParam param) {
PageParam page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List list = baseMapper.selectPageRel(page, param);
+ final List sites = thinkSiteService.list(new LambdaQueryWrapper().select(ThinkSite::getId,ThinkSite::getName));
+ final Map> collect = sites.stream().collect(Collectors.groupingBy(ThinkSite::getId));
+ list.forEach(d -> {
+ final ArrayList siteNames = new ArrayList<>();
+ final String sid = d.getSid();
+ final String[] split = sid.split(",");
+ for(String siteId : split){
+ final List thinkSites = collect.get(Integer.valueOf(siteId));
+ if (!CollectionUtils.isEmpty(thinkSites)) {
+ final String name = thinkSites.get(0).getName();
+ siteNames.add(name);
+ }
+ }
+ d.setSiteNames(String.join(",",siteNames));
+ });
return new PageResult<>(list, page.getTotal());
}
diff --git a/src/test/java/com/gxwebsoft/TestMain.java b/src/test/java/com/gxwebsoft/TestMain.java
index 0b07275..3f760bf 100644
--- a/src/test/java/com/gxwebsoft/TestMain.java
+++ b/src/test/java/com/gxwebsoft/TestMain.java
@@ -1,11 +1,13 @@
package com.gxwebsoft;
import cn.hutool.core.util.NumberUtil;
+import com.gxwebsoft.think.entity.ThinkOrder;
+import com.gxwebsoft.think.service.ThinkOrderService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
+import javax.annotation.Resource;
import java.math.BigDecimal;
-import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;