feature : (WIP) Expenses overview + transactions VIEW

pull/6221/head
Gauthier LO 2023-09-12 12:26:51 +02:00
parent fd35ea1c3e
commit cff04fe906
17 changed files with 298 additions and 21 deletions

View File

@ -318,7 +318,7 @@ public class InvoiceController {
((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername(), ((LoginUser) SecurityUtils.getSubject().getPrincipal()).getUsername(),
shopIds); shopIds);
List<String> shopIdList = Arrays.asList(shopIds.split(",")); List<String> shopIdList = Arrays.asList(shopIds.split(","));
List<PlatformOrder> orders = platformOrderService.findUninvoicedOrdersByShopForClient(shopIdList); List<PlatformOrder> orders = platformOrderService.findUninvoicedOrdersByShopForClient(shopIdList, Collections.singletonList(1));
IPage<PlatformOrder> page = new Page<>(); IPage<PlatformOrder> page = new Page<>();
page.setRecords(orders); page.setRecords(orders);
page.setTotal(orders.size()); page.setTotal(orders.size());
@ -559,12 +559,12 @@ public class InvoiceController {
} }
@GetMapping(value = "/checkInvoiceValidity") @GetMapping(value = "/checkInvoiceValidity")
public Result<?> checkInvoiceValidity(@RequestParam("invoiceID") String invoiceID, @RequestParam("email") String email, @RequestParam("orgCode") String orgCode) { public Result<?> checkInvoiceValidity(@RequestParam("invoiceNumber") String invoiceNumber, @RequestParam("email") String email, @RequestParam("orgCode") String orgCode) {
String invoiceNumber; String invoiceID;
String customerFullName; String customerFullName;
invoiceNumber = iShippingInvoiceService.getShippingInvoiceNumber(invoiceID); invoiceID = iShippingInvoiceService.getShippingInvoiceId(invoiceNumber);
// if invoice exists // if invoice exists
if (invoiceNumber == null) { if (invoiceID == null) {
return Result.error("Error 404 page not found."); return Result.error("Error 404 page not found.");
} }
// if user is a customer, we check if he's the owner of the shops // if user is a customer, we check if he's the owner of the shops

View File

@ -450,7 +450,6 @@ public class ShippingInvoiceController {
@GetMapping(value = "/sendDetailsByEmail") @GetMapping(value = "/sendDetailsByEmail")
public Result<?> sendDetailsByEmail(@RequestParam("invoiceNumber") String invoiceNumber, public Result<?> sendDetailsByEmail(@RequestParam("invoiceNumber") String invoiceNumber,
@RequestParam("invoiceID") String invoiceID,
@RequestParam("email") String email, @RequestParam("email") String email,
@RequestParam("invoiceEntity") String invoiceEntity) throws Exception { @RequestParam("invoiceEntity") String invoiceEntity) throws Exception {
String filePath = getInvoiceList(invoiceNumber, "detail"); String filePath = getInvoiceList(invoiceNumber, "detail");
@ -460,7 +459,6 @@ public class ShippingInvoiceController {
Map <String, Object> templateModel = new HashMap<>(); Map <String, Object> templateModel = new HashMap<>();
templateModel.put("fileType", fileType); templateModel.put("fileType", fileType);
templateModel.put("invoiceEntity", invoiceEntity); templateModel.put("invoiceEntity", invoiceEntity);
templateModel.put("invoiceID", invoiceID);
templateModel.put("invoiceNumber", invoiceNumber); templateModel.put("invoiceNumber", invoiceNumber);
Session session = Session.getInstance(prop, new Authenticator() { Session session = Session.getInstance(prop, new Authenticator() {

View File

@ -0,0 +1,92 @@
package org.jeecg.modules.business.controller.client;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.business.domain.shippingInvoice.ShippingInvoiceFactory;
import org.jeecg.modules.business.entity.PlatformOrder;
import org.jeecg.modules.business.mapper.*;
import org.jeecg.modules.business.service.*;
import org.jeecg.modules.business.vo.ShippingFeesEstimation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Api(tags = "Transaction")
@RestController
@RequestMapping("/transaction")
@Slf4j
public class TransactionController {
@Autowired
private TransactionMapper transactionMapper;
@Autowired
private IPlatformOrderService platformOrderService;
@Autowired
private IShopService shopService;
@Autowired
ShippingInvoiceMapper shippingInvoiceMapper;
@Autowired
PlatformOrderMapper platformOrderMapper;
@Autowired
ClientMapper clientMapper;
@Autowired
ShopMapper shopMapper;
@Autowired
LogisticChannelPriceMapper logisticChannelPriceMapper;
@Autowired
LogisticChannelMapper logisticChannelMapper;
@Autowired
IPlatformOrderContentService platformOrderContentService;
@Autowired
ISkuDeclaredValueService skuDeclaredValueService;
@Autowired
FactureDetailMapper factureDetailMapper;
@Autowired
CountryService countryService;
@Autowired
IPurchaseOrderService purchaseOrderService;
@Autowired
PurchaseOrderContentMapper purchaseOrderContentMapper;
@Autowired
SkuPromotionHistoryMapper skuPromotionHistoryMapper;
@Autowired
ExchangeRatesMapper exchangeRatesMapper;
@Autowired
ISavRefundWithDetailService savRefundWithDetailService;
@Autowired
ISavRefundService savRefundService;
@GetMapping(value="/list")
public Result<?> list() {
return Result.ok(transactionMapper.list());
}
@GetMapping(value="/listByClient")
public Result<?> listByClientId(@RequestParam("clientId") String clientId) {
return Result.ok(transactionMapper.listByClientId(clientId));
}
@GetMapping(value="/debit")
public Result<?> debit(@RequestParam("clientId") String clientId) {
List<String> errorMessages = new ArrayList<>();
List<String> shopIds = shopService.listIdByClient(clientId);
List<PlatformOrder> orders = platformOrderService.findUninvoicedOrdersByShopForClient(shopIds, Arrays.asList(1,2,3));
List<String> orderIds = orders.stream().map(PlatformOrder::getId).collect(Collectors.toList());
System.out.println("Orders size : " + orderIds.size());
System.out.println("Orders : " + orderIds);
ShippingInvoiceFactory factory = new ShippingInvoiceFactory(
platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper,
platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper,
purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService);
List<ShippingFeesEstimation> estimations = factory.getEstimations(clientId, orderIds, errorMessages);
System.out.println("Estimation size : " + estimations.size());
for(ShippingFeesEstimation estimation: estimations) {
System.out.println("estimation : " + estimation.getDueForProcessedOrders());
}
return Result.ok(estimations);
}
}

View File

@ -0,0 +1,101 @@
package org.jeecg.modules.business.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: transaction
* @Author: jeecg-boot
* @Date: 2023-09-08
* @Version: V1.0
*/
@Data
@TableName("transaction")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="transaction对象", description="transaction")
public class Transaction implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**type*/
@Excel(name = "type", width = 15)
@ApiModelProperty(value = "type")
private java.lang.String type;
/**client code*/
@Excel(name = "client code", width = 15)
@ApiModelProperty(value = "client ID")
private java.lang.String clientId;
/**proof*/
@Excel(name = "proof", width = 15)
private transient java.lang.String paymentProofString;
private byte[] paymentProof;
public byte[] getPaymentProof(){
if(paymentProofString==null){
return null;
}
try {
return paymentProofString.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
public String getPaymentProofString(){
if(paymentProof==null || paymentProof.length==0){
return "";
}
try {
return new String(paymentProof,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "";
}
/**invoice number*/
@Excel(name = "invoice number", width = 15)
@ApiModelProperty(value = "invoice number")
private java.lang.String invoiceNumber;
/**amount*/
@Excel(name = "amount", width = 15)
@ApiModelProperty(value = "amount")
private java.math.BigDecimal amount;
/**currency*/
@Excel(name = "currency", width = 15)
@ApiModelProperty(value = "currency")
private java.lang.String currency;
}

View File

@ -187,5 +187,5 @@ public interface PlatformOrderMapper extends BaseMapper<PlatformOrder> {
void cancelInvoice(@Param("invoiceNumber") String invoiceNumber); void cancelInvoice(@Param("invoiceNumber") String invoiceNumber);
void cancelBatchInvoice(@Param("invoiceNumbers") List<String> invoiceNumbers); void cancelBatchInvoice(@Param("invoiceNumbers") List<String> invoiceNumbers);
List<PlatformOrder> findUninvoicedOrdersByShopForClient(@Param("shopIds") List<String> shopIds); List<PlatformOrder> findUninvoicedOrdersByShopForClient(@Param("shopIds") List<String> shopIds, @Param("erpStatuses") List<Integer> erpStatuses);
} }

View File

@ -18,7 +18,7 @@ import java.util.List;
*/ */
@Repository @Repository
public interface ShippingInvoiceMapper extends BaseMapper<ShippingInvoice> { public interface ShippingInvoiceMapper extends BaseMapper<ShippingInvoice> {
String fetchShippingInvoiceNumber(@Param("invoiceID") String invoiceID); String fetchShippingInvoiceId(@Param("invoiceNumber") String invoiceNumber);
ShippingInvoice fetchShippingInvoice(@Param("invoiceNumber") String invoiceNumber); ShippingInvoice fetchShippingInvoice(@Param("invoiceNumber") String invoiceNumber);
List<PlatformOrder> fetchPlatformOrder(@Param("invoiceNumber") String invoiceNumber); List<PlatformOrder> fetchPlatformOrder(@Param("invoiceNumber") String invoiceNumber);
List<PlatformOrderContent> fetchPlatformOrderContent(@Param("platformOrderId") String platformOrderId); List<PlatformOrderContent> fetchPlatformOrderContent(@Param("platformOrderId") String platformOrderId);

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.business.entity.Transaction;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface TransactionMapper extends BaseMapper<Transaction> {
List<Transaction> list();
List<Transaction> listByClientId(@Param("clientId") String clientId);
}

View File

@ -543,7 +543,17 @@
<select id="findUninvoicedOrdersByShopForClient" resultType="org.jeecg.modules.business.entity.PlatformOrder"> <select id="findUninvoicedOrdersByShopForClient" resultType="org.jeecg.modules.business.entity.PlatformOrder">
SELECT * SELECT *
FROM platform_order FROM platform_order
WHERE erp_status = 1 WHERE erp_status IN
<foreach
collection="erpStatuses"
separator=","
open="("
close=")"
index="index"
item="erpStatus"
>
#{erpStatus}
</foreach>
AND shipping_invoice_number IS NULL AND shipping_invoice_number IS NULL
AND shop_id IN AND shop_id IN
<foreach <foreach

View File

@ -9,10 +9,10 @@
JOIN platform_order po on s.id = po.shop_id JOIN platform_order po on s.id = po.shop_id
WHERE po.shipping_invoice_number = #{invoiceNumber} WHERE po.shipping_invoice_number = #{invoiceNumber}
</select> </select>
<select id="fetchShippingInvoiceNumber" resultType="java.lang.String"> <select id="fetchShippingInvoiceId" resultType="java.lang.String">
SELECT invoice_number SELECT id
FROM shipping_invoice s FROM shipping_invoice
WHERE s.id = #{invoiceID} WHERE invoice_number = #{invoiceNumber}
</select> </select>
<select id="fetchShippingInvoice" resultType="org.jeecg.modules.business.entity.ShippingInvoice"> <select id="fetchShippingInvoice" resultType="org.jeecg.modules.business.entity.ShippingInvoice">
SELECT total_amount, discount_amount, final_amount, paid_amount SELECT total_amount, discount_amount, final_amount, paid_amount

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.business.mapper.TransactionMapper">
<select id="list" resultType="org.jeecg.modules.business.entity.Transaction">
SELECT * FROM transaction;
</select>
<select id="listByClientId" resultType="org.jeecg.modules.business.entity.Transaction">
SELECT *
FROM transaction
WHERE client_id = #{clientId}
ORDER BY create_time;
</select>
</mapper>

View File

@ -183,5 +183,5 @@ public interface IPlatformOrderService extends IService<PlatformOrder> {
* @param shopIds list of shop id * @param shopIds list of shop id
* @return list of orders * @return list of orders
*/ */
List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds); List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds, List<Integer> erpStatuses);
} }

View File

@ -37,7 +37,7 @@ public interface IShippingInvoiceService extends IService<ShippingInvoice> {
* *
*/ */
public void delBatchMain(Collection<? extends Serializable> idList); public void delBatchMain(Collection<? extends Serializable> idList);
public String getShippingInvoiceNumber(String invoiceID); public String getShippingInvoiceId(String invoiceNumber);
public ShippingInvoice getShippingInvoice(String invoiceNumber); public ShippingInvoice getShippingInvoice(String invoiceNumber);
public List<PlatformOrder> getPlatformOrder(String invoiceNumber); public List<PlatformOrder> getPlatformOrder(String invoiceNumber);
public List<PlatformOrderContent> getPlatformOrderContent(String platformOrderId); public List<PlatformOrderContent> getPlatformOrderContent(String platformOrderId);

View File

@ -0,0 +1,18 @@
package org.jeecg.modules.business.service;
import org.jeecg.modules.business.entity.Transaction;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Description: transaction
* @Author: jeecg-boot
* @Date: 2023-09-08
* @Version: V1.0
*/
@Repository
public interface ITransactionService extends IService<Transaction> {
List<Transaction> list();
}

View File

@ -395,7 +395,7 @@ public class PlatformOrderServiceImpl extends ServiceImpl<PlatformOrderMapper, P
} }
@Override @Override
public List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds) { public List<PlatformOrder> findUninvoicedOrdersByShopForClient(List<String> shopIds, List<Integer> erpStatuses) {
return platformOrderMap.findUninvoicedOrdersByShopForClient(shopIds); return platformOrderMap.findUninvoicedOrdersByShopForClient(shopIds, erpStatuses);
} }
} }

View File

@ -72,8 +72,8 @@ public class ShippingInvoiceServiceImpl extends ServiceImpl<ShippingInvoiceMappe
@Override @Override
@Transactional @Transactional
public String getShippingInvoiceNumber(String invoiceID) { public String getShippingInvoiceId(String invoiceNumber) {
return shippingInvoiceMapper.fetchShippingInvoiceNumber(invoiceID); return shippingInvoiceMapper.fetchShippingInvoiceId(invoiceNumber);
} }
@Override @Override
@Transactional @Transactional

View File

@ -0,0 +1,30 @@
package org.jeecg.modules.business.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.entity.Transaction;
import org.jeecg.modules.business.mapper.TransactionMapper;
import org.jeecg.modules.business.service.ITransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
/**
* @Description: transaction
* @Author: jeecg-boot
* @Date: 2023-09-08
* @Version: V1.0
*/
@Service
@Slf4j
public class TransactionServiceImpl extends ServiceImpl<TransactionMapper, Transaction> implements ITransactionService {
@Autowired
private TransactionMapper transactionMapper;
@Override
public List<Transaction> list() {
return transactionMapper.list();
}
}

View File

@ -30,7 +30,7 @@
<td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td> <td style="padding:10px 0;"><b>Client :</b> ${invoiceEntity}</td>
</tr> </tr>
<tr> <tr>
<td style="padding:10px 0;"><b>Numéro de facture :</b> <a href="http://app.wia-sourcing.com/business/admin/shippingInvoice/Invoice?invoiceID=${invoiceID}"> ${invoiceNumber} </a></td> <td style="padding:10px 0;"><b>Numéro de facture :</b> <a href="http://app.wia-sourcing.com/business/admin/shippingInvoice/Invoice?invoice=${invoiceNumber}"> ${invoiceNumber} </a></td>
</tr> </tr>
<tr> <tr>
<td style="padding:35px 0 5px 0;">Merci dutiliser nos services.</td> <td style="padding:35px 0 5px 0;">Merci dutiliser nos services.</td>