Przeglądaj źródła

贸易结算导出接口

xucaiqin 2 lat temu
rodzic
commit
8ec51d1dec

+ 37 - 32
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/KwpSettlementTradeController.java

@@ -1,20 +1,22 @@
 package com.sckw.payment.controller;
 
-import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.payment.model.constant.TradeUnitType;
-import com.sckw.payment.model.dto.ISettlement;
+import com.sckw.payment.model.dto.SettlementTradeDto;
 import com.sckw.payment.model.vo.req.SettlementTradeReq;
-import com.sckw.payment.model.vo.res.SettlementLogisticsVo;
+import com.sckw.payment.model.vo.res.SettlementTradeVo;
 import com.sckw.payment.service.KwpSettlementTradeService;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 import org.springframework.beans.BeanUtils;
 import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 import java.util.stream.Collectors;
@@ -39,7 +41,7 @@ public class KwpSettlementTradeController {
      * @param settlementReq
      * @return
      */
-    @PostMapping(name = "收款-销售结算单列表", path = "pageSellList")
+    @PostMapping("pageSellList")
     public HttpResult pageListCollection(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
         settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
@@ -53,7 +55,7 @@ public class KwpSettlementTradeController {
      * @param settlementReq
      * @return
      */
-    @PostMapping(name = "收款-表头统计数量", path = "getSellCount")
+    @PostMapping("getSellCount")
     public HttpResult getCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
         settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
@@ -68,7 +70,7 @@ public class KwpSettlementTradeController {
      * @param settlementReq
      * @return
      */
-    @PostMapping(name = "收款-表尾金额结算数据", path = "getSellSum")
+    @PostMapping("getSellSum")
     public HttpResult getSellSum(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
@@ -77,18 +79,19 @@ public class KwpSettlementTradeController {
         return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
     }
 
-    @PostMapping(name = "收款-根据ids导出销售结算单列表", path = "exportCollection")
+    /**
+     * 导出销售结算单列表
+     *
+     * @param response
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping("exportCollection")
     public HttpResult exportCollection(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.check();
-        List<ISettlement> list;
         settlementReq.setUnitType(TradeUnitType.PURCHASE);
         settlementReq.setUnitTypeTwo(TradeUnitType.SELL);
-        if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            PageRes<ISettlement> pageResult = kwpSettlementTradeService.pageListCollection(settlementReq);
-            list = pageResult.getList();
-        } else {
-            list = kwpSettlementTradeService.selectList(settlementReq.getIdList(), TradeUnitType.PURCHASE);
-        }
+        List<SettlementTradeDto> list = kwpSettlementTradeService.exportList(settlementReq, settlementReq.getIdList());
         return this.export(response, list);
     }
 
@@ -101,7 +104,7 @@ public class KwpSettlementTradeController {
      * @param settlementReq
      * @return
      */
-    @PostMapping(name = "付款-采购结算单列表", path = "pagePurchaseList")
+    @PostMapping("pagePurchaseList")
     public HttpResult pageListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.SELL);
@@ -115,7 +118,7 @@ public class KwpSettlementTradeController {
      * @param settlementReq
      * @return
      */
-    @PostMapping(name = "收款-表头统计数量", path = "getPurchaseCount")
+    @PostMapping("getPurchaseCount")
     public HttpResult getPurchaseCount(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.SELL);
@@ -130,7 +133,7 @@ public class KwpSettlementTradeController {
      * @param settlementReq
      * @return
      */
-    @PostMapping(name = "收款-物流结算订单列表头部汇总数量", path = "getPurchaseSum")
+    @PostMapping("getPurchaseSum")
     public HttpResult getCountListPayment(@RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.check();
         settlementReq.setUnitType(TradeUnitType.SELL);
@@ -139,36 +142,38 @@ public class KwpSettlementTradeController {
         return HttpResult.ok(kwpSettlementTradeService.getCountListCollection(settlementReq));
     }
 
-    @PostMapping(name = "付款-根据ids导出采购结算单列表", path = "exportPayment")
+    /**
+     * 导出采购结算单列表
+     *
+     * @param response
+     * @param settlementReq
+     * @return
+     */
+    @PostMapping("exportPayment")
     public HttpResult exportPayment(HttpServletResponse response, @RequestBody @Valid SettlementTradeReq settlementReq) {
         settlementReq.check();
-        List<ISettlement> list;
         settlementReq.setUnitType(TradeUnitType.SELL);
         settlementReq.setUnitTypeTwo(TradeUnitType.PURCHASE);
-        if (CollectionUtils.isEmpty(settlementReq.getIdList())) {
-            PageRes<ISettlement> pageResult = kwpSettlementTradeService.pageListCollection(settlementReq);
-            list = pageResult.getList();
-        } else {
-            list = kwpSettlementTradeService.selectList(settlementReq.getIdList(), TradeUnitType.SELL);
-        }
+        List<SettlementTradeDto> list = kwpSettlementTradeService.exportList(settlementReq, settlementReq.getIdList());
         return this.export(response, list);
     }
+
     /**
      * 导出
      *
      * @author Aick Spt
      * @date 2023-07-24 15:49
      */
-    private HttpResult export(HttpServletResponse response, List<ISettlement> list) {
+    private HttpResult export(HttpServletResponse response, List<SettlementTradeDto> list) {
         if (CollectionUtils.isEmpty(list)) {
             return HttpResult.error("没有可导出的数据");
         }
-        List<SettlementLogisticsVo> collect = list.stream().map(a -> {
-            SettlementLogisticsVo settlementLogisticsVo = new SettlementLogisticsVo();
-            BeanUtils.copyProperties(a, settlementLogisticsVo);
-            return settlementLogisticsVo;
+        List<SettlementTradeVo> collect = list.stream().map(a -> {
+            SettlementTradeVo settlementTradeVo = new SettlementTradeVo();
+            BeanUtils.copyProperties(a, settlementTradeVo);
+            return settlementTradeVo;
         }).collect(Collectors.toList());
-        ExcelUtil.downData(response, SettlementLogisticsVo.class, collect);
+        ExcelUtil.downData(response, SettlementTradeVo.class, collect);
         return null;
     }
 

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/dao/KwpSettlementTradeMapper.java

@@ -78,4 +78,5 @@ public interface KwpSettlementTradeMapper extends BaseMapper<KwpSettlementTrade>
 
     List<KwpSettlementRecord> queryRecord();
 
+    List<SettlementTradeDto> exportList(@Param("settlementReq")SettlementTradeReq settlementReq, @Param("idList")List<Long> idList);
 }

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/constant/PayCenterEnum.java

@@ -32,6 +32,7 @@ public enum PayCenterEnum {
     ADVANCE_PAY_DETAIL("/v1/wallet/advancepay/detail", "预付订单详情"),
     ADVANCE_PAY_APPLY("/v1/wallet/advancepay/apply", "发起预付"),
     ADVANCE_PAY_INDEX("/v1/wallet/advancepay/index", "预付订单清单"),
+    ADVANCE_PAY_INDEX2("/v2/wallet/advancepay/index", "预付订单清单"),
     ADVANCE_PAY_WALLETS("/v2/advancepay/wallets", "钱包预付列表"),
     ADVANCE_PAY_PAY_CHANNELS("/v2/advancepay/pay/channels", "钱包预付通道统计"),
     ADVANCE_PAY_RECEIVE("/v2/advancepay/receives", "钱包预收列表"),

+ 19 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/SettlementTradeDto.java

@@ -72,6 +72,9 @@ public class SettlementTradeDto implements ISettlement {
      * 对账采购财务联系人名称
      */
     private String auditUser;
+    //导出时的财务联系人
+    private String contacts;
+    private String phone;
 
     /**
      * 对账采购财务联系人电话
@@ -131,6 +134,22 @@ public class SettlementTradeDto implements ISettlement {
     //百分比
     private String percentage;
 
+    public String getContacts() {
+        return contacts;
+    }
+
+    public void setContacts(String contacts) {
+        this.contacts = contacts;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
     public String getPercentage() {
         return percentage;
     }

+ 52 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/PrePayIndex2.java

@@ -0,0 +1,52 @@
+package com.sckw.payment.model.dto.wallet;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+public class PrePayIndex2 implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -6059595444592551329L;
+
+    @JSONField(name = "order_no")
+    private String orderNo;
+    @JSONField(name = "channel")
+    private String channel;
+    /**
+     * 支付通道名
+     */
+    @JSONField(name = "channel_label")
+    private String channelLabel;
+    /**
+     * 预付金额
+     */
+    @JSONField(name = "money")
+    private BigDecimal money;
+    /**
+     * 预付后余额
+     */
+    @JSONField(name = "ap_balance")
+    private BigDecimal apBalance;
+
+    @JSONField(name = "create_time")
+    private String createTime;
+
+    @JSONField(name = "remarks")
+    private String remarks;
+
+    @JSONField(name = "status_label")
+    private String statusLabel;
+    /**
+     * 订单状态
+     */
+    @JSONField(name = "status")
+    private int status;
+
+
+}

+ 160 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/excel/SettlementLogisticsExport.java

@@ -0,0 +1,160 @@
+package com.sckw.payment.model.vo.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author Aick Spt
+ * @date 2023-07-21 15:28
+ */
+@Getter
+@Setter
+@ExcelContext(fileName = "物流结算订单列表", sheetName = "物流结算订单列表")
+public class SettlementLogisticsExport {
+
+    /**
+     * 主键
+     */
+    @ExcelProperty(value = "主键")
+    private Long id;
+
+    /**
+     * 结算单编号
+     */
+    @ExcelProperty(value = "结算单编号")
+    private String slOrderNo;
+
+    /**
+     * 名称
+     */
+    @ExcelProperty(value = "名称")
+    private String name;
+
+    /**
+     * 对账金额
+     */
+    @ExcelProperty(value = "对账金额")
+    private BigDecimal totalPrice;
+
+    /**
+     * 已收账款
+     */
+    @ExcelProperty(value = "已收账款")
+    private BigDecimal actualPrice;
+
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @ExcelProperty(value = "预计收款日期")
+    private Date receiptTime;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 对账托运方财务联系人
+     */
+    @ExcelProperty(value = "对账托运方财务联系人")
+    private String auditUser;
+
+    /**
+     * 对账托运方财务联系人电话
+     */
+    @ExcelProperty(value = "对账托运方财务联系人电话")
+    private String auditPhone;
+
+    /**
+     * 对账承运方财务联系人
+     */
+    @ExcelProperty(value = "对账承运方财务联系人")
+    private String successUser;
+
+    /**
+     * 对账承运方财务联系人电话
+     */
+    @ExcelProperty(value = "对账承运方财务联系人电话")
+    private String successPhone;
+
+
+    @ExcelProperty(value = "状态")
+    private String statusText;
+
+    /**
+     * 创建人名称
+     */
+    @ExcelProperty(value = "创建人名称")
+    private String createByText;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ExcelProperty(value = "创建时间")
+    private Date createTime;
+
+
+    /**
+     * 更新人名称
+     */
+    @ExcelProperty(value = "更新人名称")
+    private String updateByText;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ExcelProperty(value = "更新时间")
+    private Date updateTime;
+
+
+    /**
+     * 对账单名称
+     */
+    @ExcelProperty(value = "对账单名称")
+    private String ledgerName;
+
+
+    /**
+     * 交易方式
+     */
+    @ExcelProperty(value = "交易方式")
+    private String trading;
+
+    /**
+     * 对账单编号
+     */
+    @ExcelProperty(value = "对账单编号")
+    private String lLedgerNo;
+
+
+    /**
+     * 客户名称
+     */
+    @ExcelProperty(value = "客户名称")
+    private String firmName;
+
+
+    /**
+     * 实际应收还款
+     */
+    @ExcelProperty(value = "实际应收还款")
+    private BigDecimal ledgerSettlePrice;
+
+    /**
+     * 剩余待还款
+     */
+    @ExcelProperty(value = "剩余待还款")
+    private BigDecimal residuePrice;
+
+
+}

+ 161 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/vo/res/SettlementTradeVo.java

@@ -0,0 +1,161 @@
+package com.sckw.payment.model.vo.res;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.sckw.excel.annotation.ExcelContext;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 运营端 贸易结算
+ *
+ * @author 徐才钦
+ * @date 2023-07-20 12:26
+ */
+@Getter
+@Setter
+@ExcelContext(fileName = "贸易结算订单列表", sheetName = "贸易结算订单列表")
+public class SettlementTradeVo {
+    /**
+     * 主键
+     */
+    @ExcelProperty(value = "主键")
+    private Long id;
+
+    /**
+     * 结算单编号
+     */
+    @ExcelProperty(value = "结算单编号")
+    private String stOrderNo;
+
+    /**
+     * 名称
+     */
+    @ExcelProperty(value = "名称")
+    private String name;
+
+    /**
+     * 对账金额
+     */
+    @ExcelProperty(value = "对账金额")
+    private BigDecimal totalPrice;
+
+    /**
+     * 已收账款
+     */
+    @ExcelProperty(value = "已收账款")
+    private BigDecimal actualPrice;
+
+    /**
+     * 预计收款日期
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @ExcelProperty(value = "预计收款日期")
+    private Date receiptTime;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 对账托运方财务联系人
+     */
+    @ExcelProperty(value = "对账托运方财务联系人")
+    private String auditUser;
+
+    /**
+     * 对账托运方财务联系人电话
+     */
+    @ExcelProperty(value = "对账托运方财务联系人电话")
+    private String auditPhone;
+
+    /**
+     * 对账承运方财务联系人
+     */
+    @ExcelProperty(value = "对账承运方财务联系人")
+    private String successUser;
+
+    /**
+     * 对账承运方财务联系人电话
+     */
+    @ExcelProperty(value = "对账承运方财务联系人电话")
+    private String successPhone;
+
+
+    @ExcelProperty(value = "状态")
+    private String statusLabel;
+
+    /**
+     * 创建人名称
+     */
+    @ExcelProperty(value = "创建人名称")
+    private String createByLabel;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ExcelProperty(value = "创建时间")
+    private Date createTime;
+
+
+    /**
+     * 更新人名称
+     */
+    @ExcelProperty(value = "更新人名称")
+    private String updateByLabel;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ExcelProperty(value = "更新时间")
+    private Date updateTime;
+
+
+    /**
+     * 对账单名称
+     */
+    @ExcelProperty(value = "对账单名称")
+    private String ledgerName;
+
+
+    /**
+     * 交易方式
+     */
+    @ExcelProperty(value = "交易方式")
+    private String trading;
+
+    /**
+     * 对账单编号
+     */
+    @ExcelProperty(value = "对账单编号")
+    private String lLedgerNo;
+
+
+    /**
+     * 客户名称
+     */
+    @ExcelProperty(value = "客户名称")
+    private String firmName;
+
+
+    /**
+     * 实际应收还款
+     */
+    @ExcelProperty(value = "实际应收还款")
+    private BigDecimal ledgerSettlePrice;
+
+    /**
+     * 剩余待还款
+     */
+    @ExcelProperty(value = "剩余待还款")
+    private BigDecimal residuePrice;
+
+
+}

+ 4 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/KwpSettlementTradeService.java

@@ -284,4 +284,8 @@ public class KwpSettlementTradeService {
     public List<MoneyType> moneySum(Long entId, List<LocalDateTime> cur, List<LocalDateTime> pre, Integer unitType) {
         return settlementTradeMapper.sumMoneyType(entId, cur, pre, unitType);
     }
+
+    public List<SettlementTradeDto> exportList(SettlementTradeReq settlementReq, List<Long> idList) {
+        return settlementTradeMapper.exportList(settlementReq,idList);
+    }
 }

+ 65 - 0
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementTradeMapper.xml

@@ -498,4 +498,69 @@
         WHERE kst.del_flag = 0
         GROUP BY kltu.top_ent_id
     </select>
+
+    <select id="exportList" resultType="com.sckw.payment.model.dto.SettlementTradeDto">
+        select kst.id,
+               kst.status,
+               kst.st_order_no,
+               klt.t_ledger_no                                    tLedgerNo,
+               kst.create_time,
+               kst.receipt_time,
+               cast(kst.actual_price as char)                     actualPrice,
+               cast(kst.total_price as char)                      totalPrice,
+               cast((kst.total_price - kst.actual_price) as char) waitPrice,
+               (case
+                    when #{settlementReq.unitType,jdbcType=INTEGER} = 1 then klt.audit_user
+                    else klt.success_user end)  as                contacts,
+               (case
+                    when #{settlementReq.unitType,jdbcType=INTEGER} = 1 then klt.audit_phone
+                    else klt.success_phone end) as                phone,
+               kst.create_time,
+               kst.t_ledger_id,
+               klt.id                                             ledgerId,
+               klt.name,
+               klt.trading,
+               kltu.firm_name                                     firmName,
+               kst.update_by
+        from kwp_settlement_trade kst
+                 inner join kwp_ledger_trade klt on kst.t_ledger_id = klt.id and klt.del_flag = 0
+                 inner join kwp_ledger_trade_unit kltu on klt.id = kltu.t_ledger_id and kltu.del_flag = 0 and
+                                                          kltu.unit_type = #{settlementReq.unitType,jdbcType=INTEGER}
+                 inner join kwp_ledger_trade_unit kltu2 on klt.id = kltu2.t_ledger_id and kltu2.del_flag = 0 and
+                                                           kltu2.unit_type =
+                                                           #{settlementReq.unitTypeTwo,jdbcType=INTEGER}
+        <where>
+            kst.del_flag = 0
+            <choose>
+                <when test="idList != null and idList.size() != 0">
+                    and kst.id in
+                    <foreach collection="idList" open="(" separator="," close=")" item="item">
+                        #{item,jdbcType=BIGINT}
+                    </foreach>
+                </when>
+                <otherwise>
+                    and kltu2.top_ent_id = #{settlementReq.entId,jdbcType=INTEGER}
+                    <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
+                        and (
+                                    klt.name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                                or kltu.firm_name like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                                or kst.st_order_no like concat('%', #{settlementReq.keywords,jdbcType=VARCHAR}, '%')
+                            )
+                    </if>
+                    <if test="settlementReq.trading != null and settlementReq.trading != ''">
+                        and klt.trading = #{settlementReq.trading,jdbcType=VARCHAR}
+                    </if>
+                    <if test="settlementReq.status != null">
+                        and kst.status = #{settlementReq.status,jdbcType=INTEGER}
+                    </if>
+                    <if test="settlementReq.startCreateTime != null and settlementReq.startCreateTime != '' and settlementReq.endCreateTime != null and settlementReq.endCreateTime != ''">
+                        and kst.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
+                    </if>
+                    <if test="settlementReq.startReceiptTime != null and settlementReq.startReceiptTime != '' and settlementReq.endReceiptTime != null and settlementReq.endReceiptTime != ''">
+                        and kst.receipt_time between #{settlementReq.startReceiptTime,jdbcType=TIMESTAMP} and #{settlementReq.endReceiptTime,jdbcType=TIMESTAMP}
+                    </if>
+                </otherwise>
+            </choose>
+        </where>
+    </select>
 </mapper>