dongke 1 год назад
Родитель
Сommit
dc2b4a5617

+ 27 - 2
src/main/java/com/dk/oauth/controller/ReceiptController.java

@@ -1,9 +1,12 @@
 package com.dk.oauth.controller;
 
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.entity.Trade;
+import com.dk.oauth.model.pojo.Receipt;
 import com.dk.oauth.service.IReceiptService;
-import org.springframework.web.bind.annotation.RequestMapping;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 
 @Api(tags = "发票管理API接口")
@@ -16,4 +19,26 @@ public class ReceiptController{
     @Autowired
     private IReceiptService receiptService;
 
+
+    /**
+     * @desc : 新建发票
+     * @author : 王英杰
+     * @date : 2024/2/1 14:55
+     */
+    @ApiOperation(value = "新建发票", notes = "新建发票")
+    @PostMapping(value = "/insert")
+    public ResponseResultVO<?> insertReceip(@RequestBody Receipt receipt) {
+        return receiptService.insertReceip(receipt);
+    }
+
+    /**
+     * @desc : 通过交易记录 查询 对应的发票数据
+     * @author : 王英杰
+     * @date : 2023/1/9 10:41
+     */
+    @PostMapping({"/select_by_tradeid/{tradeId}"})
+    public ResponseResultVO selectByTradeId(@PathVariable String tradeId) {
+        return receiptService.selectByTradeId(tradeId);
+    }
+
 }

+ 2 - 2
src/main/java/com/dk/oauth/entity/Trade.java

@@ -76,9 +76,9 @@ public class Trade extends PageInfo<Trade> implements Serializable {
      */
     @Excel(name = "交易时间")
     @ApiModelProperty(value = "交易时间")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime tradeTime;
+    private LocalDate  tradeTime;
 
     /**
      * 交易类型 (版本升级、功能单买、。。。)

+ 6 - 1
src/main/java/com/dk/oauth/mapper/ReceiptItemMapper.java

@@ -1,14 +1,19 @@
 package com.dk.oauth.mapper;
 
+import com.dk.oauth.entity.Trade;
+import com.dk.oauth.entity.TradeResponse;
 import com.dk.oauth.model.pojo.ReceiptItem;
 import com.dk.common.mapper.BaseMapper;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
 *  发票管理 Mapper
 */
 @Repository
 public interface ReceiptItemMapper extends BaseMapper<ReceiptItem>{
-	
+
+    List<ReceiptItem> selectReceiptItem(ReceiptItem t);
 }
 

+ 25 - 0
src/main/java/com/dk/oauth/mapper/ReceiptMapper.java

@@ -2,6 +2,10 @@ package com.dk.oauth.mapper;
 
 import com.dk.oauth.model.pojo.Receipt;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.oauth.model.pojo.ReceiptSet;
+import com.dk.oauth.response.ReceiptResponse;
+import com.dk.oauth.response.ReceiptSetResponse;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**
@@ -9,6 +13,27 @@ import org.springframework.stereotype.Repository;
 */
 @Repository
 public interface ReceiptMapper extends BaseMapper<Receipt>{
+
+    /**
+        * @desc   : 根据id 进行查询
+        * @author : 王英杰
+        * @date   : 2024/8/5 10:20
+        */
+    ReceiptResponse selectById(@Param("receiptId") String receiptId);
+
+//    /**
+//        * @desc   : 编辑
+//        * @author : 王英杰
+//        * @date   : 2024/8/5 10:20
+//        */
+//    int updateById(Receipt receipt);
+//
+//    /**
+//     * @desc : 新建
+//     * @author : 王英杰
+//     * @date : 2024/2/26 10:36
+//     */
+//    int insertSingle(Receipt receipt);
 	
 }
 

+ 1 - 1
src/main/java/com/dk/oauth/mapper/TradeMapper.java

@@ -32,6 +32,6 @@ public interface TradeMapper extends BaseMapper<Trade> {
     Trade selectById(@Param("id") Integer id);
 
     int updateById(Trade t);
-
+    int updateTrade(Trade t);
 
 }

+ 17 - 5
src/main/java/com/dk/oauth/model/pojo/Receipt.java

@@ -7,6 +7,7 @@ import java.io.Serializable;
 import com.dk.common.infrastructure.annotaiton.ExportTitle;
 import com.dk.common.infrastructure.handler.*;
 import com.dk.common.model.pojo.PageInfo;
+import com.dk.oauth.entity.Trade;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.AllArgsConstructor;
@@ -18,6 +19,7 @@ import io.swagger.annotations.ApiModelProperty;
 import com.alibaba.fastjson.JSONObject;
 
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.util.List;
 import java.time.LocalDateTime;
 
@@ -30,7 +32,7 @@ import java.time.LocalDateTime;
 @EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
 @ExportTitle("发票管理")
-@TableName(value = "t_mst_receipt", autoResultMap = true)
+@TableName(value = "t_mst_receipt", autoResultMap = true, schema = "dkic_a")
 @ApiModel(value="实体类:发票管理", description="表名:t_mst_receipt")
 public class Receipt extends PageInfo<Receipt> implements Serializable {
 
@@ -41,7 +43,7 @@ public class Receipt extends PageInfo<Receipt> implements Serializable {
     /**
      * 发票ID
      */
-    @TableId(value = "receipt_id", type = IdType.AUTO)
+//    @TableId(value = "receipt_id", type = IdType.AUTO)
     @ApiModelProperty(value = "发票ID")
     @TableField(typeHandler = UuidTypeHandler.class)
     private String receiptId;
@@ -85,9 +87,9 @@ public class Receipt extends PageInfo<Receipt> implements Serializable {
      */
     @Excel(name = "申请日期")
     @ApiModelProperty(value = "申请日期")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime applyDate;
+    private LocalDate applyDate;
 
 
     /**
@@ -266,7 +268,12 @@ public class Receipt extends PageInfo<Receipt> implements Serializable {
     @TableField(typeHandler = TimestampTypeHandler.class)
     private LocalDateTime opTimestamp;
 
-
+    /**
+     * 备注
+     */
+    @Excel(name = "备注", width = 30, orderNum = "99")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
     /**
      * 数据操作数据库用户 (触发器自动处理)
      */
@@ -274,6 +281,11 @@ public class Receipt extends PageInfo<Receipt> implements Serializable {
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
+    /**
+     *  选择交易记录开发票  的 交易记录 单号list
+     */
+    @TableField(exist = false)
+    private List<Trade> tradeList ;
 
     /*
      * 相关属性

+ 1 - 1
src/main/java/com/dk/oauth/model/pojo/ReceiptFit.java

@@ -26,7 +26,7 @@ import java.util.List;
 @EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
 @ExportTitle
-@TableName(value = "t_mst_receipt_fit", autoResultMap = true)
+@TableName(value = "t_mst_receipt_fit", autoResultMap = true, schema = "dkic_a")
 @ApiModel(value="实体类:", description="表名:t_mst_receipt_fit")
 public class ReceiptFit extends PageInfo<ReceiptFit> implements Serializable {
 

+ 1 - 1
src/main/java/com/dk/oauth/model/pojo/ReceiptItem.java

@@ -30,7 +30,7 @@ import java.time.LocalDateTime;
 @EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
 @ExportTitle("发票管理")
-@TableName(value = "t_mst_receipt_item", autoResultMap = true)
+@TableName(value = "t_mst_receipt_item", autoResultMap = true, schema = "dkic_a")
 @ApiModel(value="实体类:发票管理", description="表名:t_mst_receipt_item")
 public class ReceiptItem extends PageInfo<ReceiptItem> implements Serializable {
 

+ 1 - 1
src/main/java/com/dk/oauth/model/pojo/ReceiptSet.java

@@ -29,7 +29,7 @@ import java.time.LocalDateTime;
 @EqualsAndHashCode(callSuper = true)
 @Accessors(chain = true)
 @ExportTitle("发票设置")
-@TableName(value = "t_mst_receipt_set", autoResultMap = true)
+@TableName(value = "t_mst_receipt_set", autoResultMap = true, schema = "dkic_a")
 @ApiModel(value="实体类:发票设置", description="表名:t_mst_receipt_set")
 public class ReceiptSet extends PageInfo<ReceiptSet> implements Serializable {
 

+ 293 - 0
src/main/java/com/dk/oauth/response/ReceiptResponse.java

@@ -0,0 +1,293 @@
+package com.dk.oauth.response;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.*;
+import com.dk.common.infrastructure.annotaiton.ExportTitle;
+import com.dk.common.infrastructure.handler.TimestampTypeHandler;
+import com.dk.common.infrastructure.handler.UuidTypeHandler;
+import com.dk.common.model.pojo.PageInfo;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+/**
+ *  计量单位
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = true)
+@ExportTitle("发票管理")
+@TableName(value = "t_mst_receipt", autoResultMap = true)
+@ApiModel(value="实体类:发票管理", description="表名:t_mst_receipt")
+public class ReceiptResponse    implements Serializable {
+    /*
+     * 数据库字段
+     */
+
+    /**
+     * 发票ID
+     */
+    @TableId(value = "receipt_id", type = IdType.AUTO)
+    @ApiModelProperty(value = "发票ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String receiptId;
+
+
+    /**
+     * 发票设置ID
+     */
+    @Excel(name = "发票设置ID")
+    @ApiModelProperty(value = "发票设置ID")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String receiptSetId;
+
+
+    /**
+     * 发票状态 (【系统字典】申请,开具)
+     */
+    @Excel(name = "发票状态 (【系统字典】申请,开具)")
+    @ApiModelProperty(value = "发票状态 (【系统字典】申请,开具)")
+    private String receiptStatus;
+
+
+    /**
+     * 发票类型 (【系统字典】专票,普票)
+     */
+    @Excel(name = "发票类型 (【系统字典】专票,普票)")
+    @ApiModelProperty(value = "发票类型 (【系统字典】专票,普票)")
+    private String receiptType;
+
+
+    /**
+     * 申请人
+     */
+    @Excel(name = "申请人")
+    @ApiModelProperty(value = "申请人")
+    private String applyStaff;
+
+
+    /**
+     * 申请日期
+     */
+    @Excel(name = "申请日期")
+    @ApiModelProperty(value = "申请日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDate applyDate;
+
+
+    /**
+     * 公司Id
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @Excel(name = "公司Id")
+    @ApiModelProperty(value = "公司Id")
+    private Integer cpId;
+
+
+    /**
+     * 公司名称
+     */
+    @Excel(name = "公司名称")
+    @ApiModelProperty(value = "公司名称")
+    private String cpName;
+    /**
+     * 发票类型名称
+     */
+    @Excel(name = "发票类型名称")
+    @ApiModelProperty(value = "发票类型名称")
+    private String receiptTypeName;
+
+    /**
+     * 公司税号
+     */
+    @Excel(name = "公司税号")
+    @ApiModelProperty(value = "公司税号")
+    private String taxNo;
+
+
+    /**
+     * 电子邮箱
+     */
+    @Excel(name = "电子邮箱")
+    @ApiModelProperty(value = "电子邮箱")
+    private String cpEmail;
+
+
+    /**
+     * 注册地址
+     */
+    @Excel(name = "注册地址")
+    @ApiModelProperty(value = "注册地址")
+    private String cpAddress;
+
+
+    /**
+     * 注册电话
+     */
+    @Excel(name = "注册电话")
+    @ApiModelProperty(value = "注册电话")
+    private String cpPhone;
+
+
+    /**
+     * 开户行
+     */
+    @Excel(name = "开户行")
+    @ApiModelProperty(value = "开户行")
+    private String openBank;
+
+
+    /**
+     * 银行账户
+     */
+    @Excel(name = "银行账户")
+    @ApiModelProperty(value = "银行账户")
+    private String bankAccount;
+
+
+    /**
+     * 发票金额
+     */
+    @Excel(name = "发票金额")
+    @ApiModelProperty(value = "发票金额")
+    private BigDecimal receiptAmt;
+
+
+    /**
+     * 发票内容
+     */
+    @Excel(name = "发票内容")
+    @ApiModelProperty(value = "发票内容")
+    private String receiptContent;
+
+
+    /**
+     * 开票日期
+     */
+    @Excel(name = "开票日期")
+    @ApiModelProperty(value = "开票日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime receiptDate;
+
+
+    /**
+     * 开票人
+     */
+    @Excel(name = "开票人")
+    @ApiModelProperty(value = "开票人")
+    private String receiptStaff;
+
+
+    /**
+     * 开票方名称
+     */
+    @Excel(name = "开票方名称")
+    @ApiModelProperty(value = "开票方名称")
+    private String receiptObj;
+
+
+    /**
+     * 税率
+     */
+    @Excel(name = "税率")
+    @ApiModelProperty(value = "税率")
+    private BigDecimal taxRate;
+
+
+    /**
+     * 有效标识 (1:正常 0:停用)
+     */
+    @Excel(name = "有效标识 (1:正常 0:停用)")
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private Boolean flgValid;
+
+
+    /**
+     * 创建时间 (触发器自动处理)
+     */
+    @Excel(name = "创建时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
+    @ApiModelProperty(value = "创建时间 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opCreateTime;
+
+
+    /**
+     * 创建用户 (触发器自动处理)
+     */
+    @Excel(name = "创建用户 (触发器自动处理)")
+    @ApiModelProperty(value = "创建用户 (触发器自动处理)")
+    private Long opCreateUserId;
+
+
+    /**
+     * 修改时间 (触发器自动处理)
+     */
+    @Excel(name = "修改时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
+    @ApiModelProperty(value = "修改时间 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opUpdateTime;
+
+
+    /**
+     * 修改用户 (触发器自动处理)
+     */
+    @Excel(name = "修改用户 (触发器自动处理)")
+    @ApiModelProperty(value = "修改用户 (触发器自动处理)")
+    private Long opUpdateUserId;
+
+
+    /**
+     * 数据操作应用 (触发器自动处理)
+     */
+    @Excel(name = "数据操作应用 (触发器自动处理)")
+    @ApiModelProperty(value = "数据操作应用 (触发器自动处理)")
+    private String opAppCode;
+
+
+    /**
+     * 数据时间戳 (触发器自动处理)
+     */
+    @Excel(name = "数据时间戳 (触发器自动处理)")
+    @ApiModelProperty(value = "数据时间戳 (触发器自动处理)")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime opTimestamp;
+
+
+    /**
+     * 数据操作数据库用户 (触发器自动处理)
+     */
+    @Excel(name = "数据操作数据库用户 (触发器自动处理)")
+    @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
+    private String opDbUser;
+
+
+    /*
+     * 相关属性
+     * @TableField(exist = false)
+     */
+
+    /*
+     * 关联属性 + 查询条件
+     * @TableField(exist = false)
+     */
+
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 4 - 0
src/main/java/com/dk/oauth/service/IReceiptService.java

@@ -1,6 +1,8 @@
 package com.dk.oauth.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.entity.Trade;
 import com.dk.oauth.model.pojo.Receipt;
 import com.dk.oauth.model.pojo.ReceiptFit;
 
@@ -12,5 +14,7 @@ import com.dk.oauth.model.pojo.ReceiptFit;
  */
 public interface IReceiptService extends IService<Receipt> {
 
+    ResponseResultVO insertReceip(Receipt receipt);
 
+    ResponseResultVO selectByTradeId(String tradeId);
 }

+ 58 - 1
src/main/java/com/dk/oauth/service/impl/ReceiptService.java

@@ -1,18 +1,28 @@
 package com.dk.oauth.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dk.common.response.ResponseResultUtil;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.oauth.entity.Trade;
 import com.dk.oauth.mapper.ReceiptFitMapper;
+import com.dk.oauth.mapper.ReceiptItemMapper;
+import com.dk.oauth.mapper.TradeMapper;
 import com.dk.oauth.model.pojo.Receipt;
 import com.dk.oauth.mapper.ReceiptMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.oauth.model.pojo.ReceiptFit;
+import com.dk.oauth.model.pojo.ReceiptItem;
+import com.dk.oauth.response.ReceiptResponse;
+import com.dk.oauth.response.ReceiptSetResponse;
 import com.dk.oauth.service.IReceiptService;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.List;
+import java.util.UUID;
 
 @Service
 @Transactional
@@ -20,6 +30,53 @@ public class ReceiptService extends ServiceImpl<ReceiptMapper, Receipt> implemen
 
 
     @Resource
-	private ReceiptMapper receiptMapper;
+    private ReceiptMapper receiptMapper;
+    @Resource
+    private ReceiptItemMapper receiptItemMapper;
+    @Resource
+    private TradeMapper tradeMapper;
+
+    /**
+     * @desc : 新建发票
+     * @author : 王英杰
+     * @date : 2024-02-20 13:55
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseResultVO insertReceip(Receipt receipt) {
+        String uuid = UUID.randomUUID().toString();
+        receipt.setReceiptId(uuid);
+        //新建发票管理
+        receiptMapper.insert(receipt);
+        if (receipt.getTradeList().size() > 0) {
+            for (Trade trade : receipt.getTradeList()) {
+                //新建发票管理明细
+                receiptItemMapper.insert(new ReceiptItem().setReceiptId(uuid)
+                        .setCpId(receipt.getCpId()).setTradeId(trade.getTradeId()).setItemAmt(trade.getTradeAmount()));
+                //反写交易记录
+                tradeMapper.updateTrade(new Trade().setTradeId(trade.getTradeId()).setReceiptStatus("开票状态-开票中"));
+            }
+        }
+
+        return ResponseResultUtil.success(receipt);
+    }
+
+    /**
+     * @desc :通过交易记录 查询 对应的发票数据
+     * @author : 王英杰
+     * @date : 2023/2/3 13:32
+     */
+    @Override
+    public ResponseResultVO selectByTradeId(String tradeId) {
+        List<ReceiptItem> ReceiptItemList =  receiptItemMapper.selectReceiptItem(new ReceiptItem().setTradeId(Integer.valueOf(tradeId)));
+        if(ReceiptItemList.size()>0){
+            ReceiptItem receiptItem = ReceiptItemList.get(0);
+            ReceiptResponse receiptResponse = receiptMapper.selectById(receiptItem.getReceiptId());
+            return ResponseResultUtil.success(receiptResponse);
+        }else{
+            return ResponseResultUtil.success("没有相关数据");
+        }
+
 
+    }
 }

+ 10 - 1
src/main/resources/mapper/ReceiptItemMapper.xml

@@ -85,7 +85,16 @@
             limit #{end} offset #{start}
         </if>
     </select>
-
+    <!-- 查询表t_mst_receipt_item,(条件查询+分页)列表 -->
+    <select id="selectReceiptItem" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_a.t_mst_receipt_item
+        <include refid="Condition"/>
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
+    </select>
     <!-- 查询表t_mst_receipt_item,(条件查询)个数 -->
     <select id="countByCond" resultType="Long">
         SELECT

+ 97 - 5
src/main/resources/mapper/ReceiptMapper.xml

@@ -7,15 +7,21 @@
     <sql id="Base_Column_List">
         receipt_id, receipt_set_id, receipt_status, receipt_type, apply_staff, apply_date, cp_id, cp_name, tax_no, cp_email, cp_address, cp_phone, open_bank, bank_account, receipt_amt, receipt_content, receipt_date, receipt_staff, receipt_obj, tax_rate, flg_valid, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
     </sql>
-
+    <sql id="Base_Column_List_tmr">
+        tmr.receipt_id, tmr.receipt_set_id, tmr.receipt_status, tmr.receipt_type, tmr.apply_staff, tmr.apply_date,
+    tmr.cp_id, tmr.cp_name, tmr.tax_no, tmr.cp_email, tmr.cp_address, tmr.cp_phone, tmr.open_bank, tmr.bank_account,
+    tmr.receipt_amt, tmr.receipt_content, tmr.receipt_date, tmr.receipt_staff, tmr.receipt_obj, tmr.tax_rate,
+    tmr.flg_valid, tmr.op_create_time, tmr.op_create_user_id, tmr.op_update_time, tmr.op_update_user_id,
+    tmr.op_app_code, tmr.op_timestamp, tmr.op_db_user
+    </sql>
     <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.dk.oauth.model.pojo.Receipt">
+    <resultMap id="BaseResultMap" type="com.dk.oauth.response.ReceiptResponse">
         <id column="receipt_id" property="receiptId"/>
                 <result column="receipt_set_id" property="receiptSetId" typeHandler="UuidTypeHandler"/>
                 <result column="receipt_status" property="receiptStatus"/>
                 <result column="receipt_type" property="receiptType"/>
                 <result column="apply_staff" property="applyStaff"/>
-            <result column="apply_date" property="applyDate" typeHandler="TimestampTypeHandler"/>
+                <result column="apply_date" property="applyDate" typeHandler="TimestampTypeHandler"/>
                 <result column="cp_id" property="cpId"/>
                 <result column="cp_name" property="cpName"/>
                 <result column="tax_no" property="taxNo"/>
@@ -24,6 +30,7 @@
                 <result column="cp_phone" property="cpPhone"/>
                 <result column="open_bank" property="openBank"/>
                 <result column="bank_account" property="bankAccount"/>
+               <result column="receiptTypeName" property="receiptTypeName"/>
                 <result column="receipt_amt" property="receiptAmt"/>
                 <result column="receipt_content" property="receiptContent"/>
             <result column="receipt_date" property="receiptDate" typeHandler="TimestampTypeHandler"/>
@@ -157,11 +164,15 @@
     <!-- 根据主键查询表t_mst_receipt的一行数据 -->
     <select id="selectById" resultMap="BaseResultMap">
         SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_mst_receipt
+        <include refid="Base_Column_List_tmr"/>
+        ,sys.f_get_name_i18n(tdk.kind_name_i18n, #{i18n} ) AS "receiptTypeName"
+        FROM dkic_a.t_mst_receipt tmr
+        LEFT join sys.t_data_kind tdk on tdk.kind_code = tmr.receipt_type
         WHERE receipt_id = #{receiptId}::uuid
     </select>
 
+
+
     <!-- 根据主键锁定表t_mst_receipt的一行数据 -->
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
         SELECT
@@ -234,4 +245,85 @@
             )
         </foreach>
     </insert>
+
+<!--    <insert id="insertSingle">-->
+<!--        INSERT INTO dkic_a.t_mst_receipt-->
+<!--        (-->
+<!--            receipt_set_id,-->
+<!--            receipt_status,-->
+<!--            receipt_type,-->
+<!--            apply_staff,-->
+<!--            apply_date,-->
+<!--            cp_id,-->
+<!--            cp_name,-->
+<!--            tax_no,-->
+<!--            cp_email,-->
+<!--            cp_address,-->
+<!--            cp_phone,-->
+<!--            open_bank,-->
+<!--            bank_account,-->
+<!--            receipt_amt,-->
+<!--            receipt_content,-->
+<!--            receipt_date,-->
+<!--            receipt_staff,-->
+<!--            receipt_obj,-->
+<!--            tax_rate,-->
+<!--            op_app_code-->
+<!--        )-->
+<!--        VALUES-->
+<!--            (-->
+<!--                #{receiptSetId, jdbcType=OTHER, typeHandler=com.example.UuidTypeHandler}::uuid, &#45;&#45; 假设使用了UUID类型处理器-->
+<!--                #{receiptStatus},-->
+<!--                #{receiptType},-->
+<!--                #{applyStaff},-->
+<!--                #{applyDate, jdbcType=TIMESTAMP},-->
+<!--                #{cpId},-->
+<!--                #{cpName},-->
+<!--                #{taxNo},-->
+<!--                #{cpEmail},-->
+<!--                #{cpAddress},-->
+<!--                #{cpPhone},-->
+<!--                #{openBank},-->
+<!--                #{bankAccount},-->
+<!--                #{receiptAmt},-->
+<!--                #{receiptContent},-->
+<!--                #{receiptDate, jdbcType=TIMESTAMP},-->
+<!--                #{receiptStaff},-->
+<!--                #{receiptObj},-->
+<!--                #{taxRate},-->
+<!--                #{opAppCode}-->
+<!--            )-->
+<!--    </insert>-->
+
+<!--    <update id="updateByIdSingle"  parameterType="com.dk.oauth.model.pojo.Receipt">-->
+<!--        UPDATE dkic_a.t_mst_receipt-->
+<!--        SET-->
+<!--        <if test="receiptStatus != null">-->
+<!--            receipt_status = #{receiptStatus,jdbcType=VARCHAR},-->
+<!--        </if>-->
+<!--        <if test="receiptType != null">-->
+<!--            receipt_type = #{receiptType,jdbcType=VARCHAR},-->
+<!--        </if>-->
+<!--        <if test="applyStaff != null">-->
+<!--            apply_staff = #{applyStaff,jdbcType=VARCHAR},-->
+<!--        </if>-->
+<!--        <if test="cpId != null">-->
+<!--            cp_id = #{cpId,jdbcType=NUMERIC},-->
+<!--        </if>-->
+<!--        <if test="cpName != null">-->
+<!--            cp_name = #{cpName,jdbcType=VARCHAR},-->
+<!--        </if>-->
+<!--        <if test="taxNo != null">-->
+<!--            tax_no = #{taxNo,jdbcType=VARCHAR},-->
+<!--        </if>-->
+<!--        <if test="cpEmail != null">-->
+<!--            cp_email = #{cpEmail,jdbcType=VARCHAR},-->
+<!--        </if>-->
+<!--        <if test="remarks != null">-->
+<!--            remarks = #{remarks,jdbcType=VARCHAR},-->
+<!--        </if>-->
+
+<!--        WHERE-->
+<!--         receipt_set_id = #{receiptSetId,typeHandler=UuidTypeHandler}-->
+<!--    </update>-->
 </mapper>

+ 12 - 7
src/main/resources/mapper/TradeMapper.xml

@@ -131,7 +131,7 @@
         SELECT
         <include refid="Base_Column_List"/>
         ,g.grade_name gradeName
-        FROM dkic_a.t_cp_trade        t
+        FROM dkic_a.t_cp_trade t
         left join sys.t_grade g on t.buy_grade_code = g.grade_code
         WHERE t.trade_id = #{id}
     </select>
@@ -146,9 +146,9 @@
         ,sys.f_get_name_i18n(tdk3.kind_name_i18n, #{i18n} ) AS "receiptStatusName"
         FROM dkic_a.t_cp_trade t
         left join sys.t_grade g on t.buy_grade_code = g.grade_code
-        LEFT JOIN sys.t_data_kind tdk1   ON tdk1.kind_code = t.trade_type
-        LEFT JOIN sys.t_data_kind tdk2   ON tdk2.kind_code = t.trade_status
-        LEFT JOIN sys.t_data_kind tdk3   ON tdk3.kind_code = t.receipt_status
+        LEFT JOIN sys.t_data_kind tdk1 ON tdk1.kind_code = t.trade_type
+        LEFT JOIN sys.t_data_kind tdk2 ON tdk2.kind_code = t.trade_status
+        LEFT JOIN sys.t_data_kind tdk3 ON tdk3.kind_code = t.receipt_status
         <include refid="Condition"/>
         order by t.trade_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
@@ -166,12 +166,17 @@
 
     <!-- 更新数据-->
     <update id="updateById">
-        update dkic_a.t_cp_trade set
-            wx_trade_no = #{wxTradeNo},
+        update dkic_a.t_cp_trade
+        set wx_trade_no  = #{wxTradeNo},
             trade_status = #{tradeStatus}
         where trade_id = #{tradeId}
     </update>
-
+    <!-- 更新数据-->
+    <update id="updateTrade">
+        update dkic_a.t_cp_trade
+        set receipt_status = #{receiptStatus}
+        where trade_id = #{tradeId}
+    </update>
     <!-- 查询表t_cp_trade,根据交易单号查数据 -->
     <select id="selectTradeByNo" resultMap="BaseResultMap">
         SELECT