浏览代码

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/entity/Order.java
#	blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescController.java
#	blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java
纪新园 2 年之前
父节点
当前提交
f4e0cf1325
共有 17 个文件被更改,包括 853 次插入194 次删除
  1. 11 0
      blade-service-api/blade-deliver-goods-api/src/main/java/org/springblade/deliver/goods/feign/IDeliveryClient.java
  2. 15 3
      blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/entity/Order.java
  3. 5 0
      blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/vo/OrderStatisticsVo.java
  4. 69 87
      blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescController.java
  5. 6 0
      blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/feign/DeliveryClient.java
  6. 5 5
      blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/impl/DeliveryServiceImpl.java
  7. 34 5
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/controller/OrderController.java
  8. 60 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/OrderStatisticsOneExcel.java
  9. 77 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/OrderStatisticsThreeExcel.java
  10. 65 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/OrderStatisticsTwoExcel.java
  11. 50 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/export/ExportOrderController.java
  12. 20 11
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.xml
  13. 53 1
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/IOrderService.java
  14. 25 2
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/BidingAgentServiceImpl.java
  15. 312 38
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java
  16. 43 41
      blade-service/trade-finance/src/main/java/org/springblade/finance/mapper/AccMapper.xml
  17. 3 1
      blade-service/trade-finance/src/main/java/org/springblade/finance/service/impl/SettlementServiceImpl.java

+ 11 - 0
blade-service-api/blade-deliver-goods-api/src/main/java/org/springblade/deliver/goods/feign/IDeliveryClient.java

@@ -26,6 +26,7 @@ public interface IDeliveryClient {
 	String GET_ORDER_MESSAGE = API_PREFIX + "getOrderMessage";
 	String SUBMITPAY = API_PREFIX +"/submitPay";
 	String GET_ORDER_DATA = API_PREFIX +"/getOrderData";
+	String GET_ORG_MESSAGE = API_PREFIX + "/getOrgMessage";
 
 	/**
 	 * 生成发货单
@@ -65,4 +66,14 @@ public interface IDeliveryClient {
 								   @RequestParam("billType") String billType,
 								   @RequestParam("tradeType") String tradeType);
 
+
+	/**
+	 * 根据销售订单系统号获取是否有收发货
+	 * @param orgOrderNo
+	 * @return
+	 */
+	@GetMapping(GET_ORG_MESSAGE)
+	List<Delivery> getOrgMessage(@RequestParam("orgOrderNo") String orgOrderNo,
+								   @RequestParam("tradeType") String tradeType);
+
 }

+ 15 - 3
blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/entity/Order.java

@@ -1192,9 +1192,21 @@ public class Order implements Serializable {
 	private String receivingStatus;
 
 	/**
-	 * 商品id
+	 * 销售退单状态
 	 */
-	@TableField(exist = false)
-	private List<Long> itemList;
+	@ApiModelProperty(value = "销售退单状态")
+	private Integer chargebackStatus;
+
+	/**
+	 * 销售退单人
+	 */
+	@ApiModelProperty(value = "销售退单人")
+	private String chargebackUser;
+
+	/**
+	 * 销售退单时间
+	 */
+	@ApiModelProperty(value = "销售退单时间")
+	private Date chargebackTime;
 
 }

+ 5 - 0
blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/vo/OrderStatisticsVo.java

@@ -174,4 +174,9 @@ public class OrderStatisticsVo implements Serializable {
 	 */
 	private List<String> date;
 
+	/**
+	 * 明细标识
+	 */
+	private String identification;
+
 }

+ 69 - 87
blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescController.java

@@ -91,8 +91,8 @@ public class CorpsDescController extends BladeController {
 		IPage<CorpsDescVO> pages = corpsDescService.selectCorpsDescPage(Condition.getPage(query), corpsDesc);
 
 		String belongtocompany = "";//所属公司ids
-		for (CorpsDescVO descVO : pages.getRecords()) {
-			if (ObjectUtil.isNotEmpty(descVO.getBelongtocompany())) {
+		for (CorpsDescVO descVO: pages.getRecords()){
+			if (ObjectUtil.isNotEmpty(descVO.getBelongtocompany())){
 				belongtocompany = belongtocompany + descVO.getBelongtocompany() + ",";
 			}
 		}
@@ -112,7 +112,7 @@ public class CorpsDescController extends BladeController {
 					}
 					item.setAdminProfilesName(stringBuffer.toString());
 				}
-				if (item.getBelongtocompany() != null) {
+				if (item.getBelongtocompany() != null){
 					if (ObjectUtil.isNotEmpty(corpsDescList)) {
 						item.setBelongCompany(corpsDescList.stream().filter(e -> e.getId().toString().equals(item.getBelongtocompany())).findFirst().get().getCname());
 					}
@@ -131,7 +131,7 @@ public class CorpsDescController extends BladeController {
 				}
 				//获取客户地址
 				List<CorpsAddr> corpsAddrList = corpsAddrService.list(new QueryWrapper<CorpsAddr>().eq("pid", item.getId()).eq("is_deleted", 0).eq("status", 0).eq("type", 0));
-				if (corpsAddrList != null && corpsAddrList.size() > 0) {
+				if (corpsAddrList != null && corpsAddrList.size()>0) {
 					item.setAddr(corpsAddrList.get(0).getDetailedAddress());
 				}
 			});
@@ -241,11 +241,11 @@ public class CorpsDescController extends BladeController {
 		if ("NotUNIQUE".equals(corpsDescService.selectCorpsDescCname(corpsDesc))) {
 			return R.data(200, "error", "客户名称已存在");
 		}
-		if (StringUtils.isBlank(corpsDesc.getLabels())) {
+		if(StringUtils.isBlank(corpsDesc.getLabels())){
 //			corpsDesc.setLabels("\"\",\"\",\"\",\"\"");
 			corpsDesc.setLabels(",,,");
 		}
-		if (ObjectUtils.isNull(corpsDesc.getCorpsTypeId())) {
+		if (ObjectUtils.isNull(corpsDesc.getCorpsTypeId())){
 			corpsDesc.setCorpsTypeId("1586314518265356290");
 		}
 		R corpsDesc1 = corpsDescService.submit(corpsDesc);
@@ -357,15 +357,15 @@ public class CorpsDescController extends BladeController {
 		lambdaQueryWrapper.eq(CorpsDesc::getTenantId, AuthUtil.getTenantId());
 		lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted, 0);
 		lambdaQueryWrapper.like(StringUtil.isNotBlank(corpsDesc.getCname()), CorpsDesc::getCname, corpsDesc.getCname());
-		if ("234557".equals(AuthUtil.getTenantId())) {
+		if ("234557".equals(AuthUtil.getTenantId())){
 //			lambdaQueryWrapper.like(StringUtil.isNotBlank(corpsDesc.getCorpType()), CorpsDesc::getCorpType, corpsDesc.getCorpType());
 			lambdaQueryWrapper.apply("find_in_set(corp_type,'" + corpsDesc.getCorpType() + "')");
-		} else {
+		}else{
 			lambdaQueryWrapper.like(StringUtil.isNotBlank(corpsDesc.getCorpType()), CorpsDesc::getCorpType, corpsDesc.getCorpType());
 		}
 
 		String role = AuthUtil.getUserRole();
-		if (!role.contains("admin")) {//admin能看全部,不是admin根据分管员查询
+		if (!role.contains("admin")){//admin能看全部,不是admin根据分管员查询
 			if (Func.isNotEmpty(corpsDesc.getAdminProfiles())) {
 				lambdaQueryWrapper.and(i -> i.like(CorpsDesc::getAdminProfiles, corpsDesc.getAdminProfiles()).or().eq(CorpsDesc::getAdminProfiles, ' ')
 					.or().isNull(CorpsDesc::getAdminProfiles));
@@ -406,8 +406,8 @@ public class CorpsDescController extends BladeController {
 		List<CorpsDescVO> listRest = new ArrayList<>();
 
 		voList.forEach(desc -> {
-			if (StringUtils.isNotBlank(desc.getInitials())) {
-				if (desc.getInitials().equals("A") || desc.getInitials().equals("a")) {
+			if (StringUtils.isNotBlank(desc.getInitials())){
+				if (desc.getInitials().equals("A") || desc.getInitials().equals("a")){
 					listA.add(desc);
 				} else if (desc.getInitials().equals("B") || desc.getInitials().equals("b")) {
 					listB.add(desc);
@@ -459,10 +459,10 @@ public class CorpsDescController extends BladeController {
 					listY.add(desc);
 				} else if (desc.getInitials().equals("Z") || desc.getInitials().equals("z")) {
 					listZ.add(desc);
-				} else {
+				}else {
 					listRest.add(desc);
 				}
-			} else {
+			}else {
 				listRest.add(desc);
 			}
 		});
@@ -510,13 +510,13 @@ public class CorpsDescController extends BladeController {
 		lambdaQueryWrapper.like(CorpsDesc::getCorpType, corpsDesc.getCorpType());
 
 		String role = AuthUtil.getUserRole();
-		if (!role.contains("admin")) {//admin能看全部,不是admin根据分管员查询
+		if (!role.contains("admin")){//admin能看全部,不是admin根据分管员查询
 			if (Func.isNotEmpty(corpsDesc.getAdminProfiles())) {
 				lambdaQueryWrapper.and(i -> i.like(CorpsDesc::getAdminProfiles, corpsDesc.getAdminProfiles()).or().eq(CorpsDesc::getAdminProfiles, ' ')
 					.or().isNull(CorpsDesc::getAdminProfiles));
 			}
 		}
-		if (!"234557".equals(AuthUtil.getTenantId())) {
+		if (!"234557".equals(AuthUtil.getTenantId())){
 			lambdaQueryWrapper.orderByAsc(CorpsDesc::getCname);
 		}
 		//获得客户信息
@@ -571,14 +571,14 @@ public class CorpsDescController extends BladeController {
 		if ("KG".equals(corpsDesc.getCorpType())) {
 			lambdaQueryWrapper.and(i -> i.like(CorpsDesc::getCorpType, "KH").or().like(CorpsDesc::getCorpType, "GYS"));
 		} else {
-			if ("234557".equals(AuthUtil.getTenantId())) {
+			if ("234557".equals(AuthUtil.getTenantId())){
 				lambdaQueryWrapper.apply("find_in_set(corp_type,'" + corpsDesc.getCorpType() + "')");
-			} else {
+			}else{
 				lambdaQueryWrapper.like(CorpsDesc::getCorpType, corpsDesc.getCorpType());
 			}
 		}
 		String role = AuthUtil.getUserRole();
-		if (!role.contains("admin")) {//admin能看全部,不是admin根据分管员查询
+		if (!role.contains("admin")){//admin能看全部,不是admin根据分管员查询
 			if (Func.isNotEmpty(corpsDesc.getAdminProfiles())) {
 				lambdaQueryWrapper.and(i -> i.like(CorpsDesc::getAdminProfiles, corpsDesc.getAdminProfiles()).or().eq(CorpsDesc::getAdminProfiles, ' ')
 					.or().isNull(CorpsDesc::getAdminProfiles));
@@ -587,7 +587,7 @@ public class CorpsDescController extends BladeController {
 		if (StringUtils.isNotBlank(corpsDesc.getBelongtocompany())) {
 			lambdaQueryWrapper.and(i -> i.eq(CorpsDesc::getBelongtocompany, corpsDesc.getBelongtocompany()).or().isNull(CorpsDesc::getBelongtocompany));
 		}
-		if (!"234557".equals(AuthUtil.getTenantId())) {
+		if (!"234557".equals(AuthUtil.getTenantId())){
 			lambdaQueryWrapper.orderByAsc(CorpsDesc::getCname);
 		}
 		List<CorpsDesc> corpsDescList = corpsDescService.list(lambdaQueryWrapper);
@@ -616,7 +616,7 @@ public class CorpsDescController extends BladeController {
 		lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted, 0);
 		lambdaQueryWrapper.eq(CorpsDesc::getTenantId, SecureUtil.getTenantId());
 		lambdaQueryWrapper.eq(CorpsDesc::getCorpType, "CD");
-		if (!"234557".equals(AuthUtil.getTenantId())) {
+		if (!"234557".equals(AuthUtil.getTenantId())){
 			lambdaQueryWrapper.orderByAsc(CorpsDesc::getCname);
 		}
 
@@ -632,18 +632,42 @@ public class CorpsDescController extends BladeController {
 	@ApiOperationSupport(order = 11)
 	@ApiOperation(value = "所有客户信息", notes = "获得客户信息")
 	public R<List<CorpsDesc>> bidingCorpsList(CorpsDescVO corpsDesc) {
-		redisClient.basicData("corps");
-		LambdaQueryWrapper<CorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-		lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted, 0);
-		lambdaQueryWrapper.eq(CorpsDesc::getTenantId, SecureUtil.getTenantId());
-		lambdaQueryWrapper.eq(CorpsDesc::getCorpType, "KH");
-		if (!"234557".equals(AuthUtil.getTenantId())) {
-			lambdaQueryWrapper.orderByAsc(CorpsDesc::getCname);
-		}
+		if (ObjectUtils.isNotNull(corpsDesc.getCorpsTypeName())){
+			LambdaQueryWrapper<CorpsType> corpsTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
+			corpsTypeLambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
+			corpsTypeLambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
+			corpsTypeLambdaQueryWrapper.eq(CorpsType::getCname, corpsDesc.getCorpsTypeName());
+			CorpsType corpsType = corpsTypeService.getOne(corpsTypeLambdaQueryWrapper);
 
-		List<CorpsDesc> corpsDescList = corpsDescService.list(lambdaQueryWrapper);
+			LambdaQueryWrapper<CorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+			lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted, 0);
+			lambdaQueryWrapper.eq(CorpsDesc::getTenantId, SecureUtil.getTenantId());
+			lambdaQueryWrapper.eq(CorpsDesc::getCorpType, "KH");
 
-		return R.data(corpsDescList);
+			if (!"234557".equals(AuthUtil.getTenantId())){
+				lambdaQueryWrapper.orderByAsc(CorpsDesc::getCname);
+			}
+
+			if (ObjectUtils.isNotNull(corpsType)) {
+				//获取客户类别对应的id
+				LambdaQueryWrapper<CorpsTypeDesc> typeDescLambdaQueryWrapper = new LambdaQueryWrapper<>();
+				typeDescLambdaQueryWrapper.eq(CorpsTypeDesc::getTenantId, SecureUtil.getTenantId());
+				typeDescLambdaQueryWrapper.eq(CorpsTypeDesc::getCorpTypeId, corpsType.getId());
+				List<CorpsTypeDesc> list = corpsTypeDescService.list(typeDescLambdaQueryWrapper);
+				if (CollectionUtils.isNotEmpty(list)) {
+					corpsDesc.setTypeList(list.stream().filter(e -> e.getCorpId() != null).map(CorpsTypeDesc::getCorpId).collect(Collectors.toList()));
+				}else{
+					return R.data(new ArrayList<>());
+				}
+				lambdaQueryWrapper.in(CollectionUtils.isNotEmpty(corpsDesc.getTypeList()), CorpsDesc::getId, corpsDesc.getTypeList());
+				List<CorpsDesc> corpsDescList = corpsDescService.list(lambdaQueryWrapper);
+				return R.data(corpsDescList);
+			} else {
+				return R.data(new ArrayList<>());
+			}
+		}else{
+			return R.data(new ArrayList<>());
+		}
 	}
 
 	/**
@@ -707,27 +731,26 @@ public class CorpsDescController extends BladeController {
 		}
 		return corpsDescService.importFactoryData(excelList, false);
 	}
-
 	/**
 	 * 获取分管员
 	 */
 	@GetMapping("/adminProfiles")
 	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "获取分管员", notes = "客户类别必传")
-	public R<List<Map<String, Object>>> adminProfiles(CorpsDescVO corpsDesc) {
-		if (StringUtils.isBlank(corpsDesc.getCorpType())) {
+	public R<List<Map<String,Object>>> adminProfiles(CorpsDescVO corpsDesc) {
+		if (StringUtils.isBlank(corpsDesc.getCorpType())){
 			throw new SecurityException("请选择要查询的客户类别");
 		}
-		if (corpsDesc.getId() == null) {
+		if (corpsDesc.getId() == null){
 			throw new SecurityException("请选择要查询的客户");
 		}
 		List<Map<String, Object>> mapList = new ArrayList<>();
 		LambdaQueryWrapper<CorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-		lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted, 0);
-		lambdaQueryWrapper.eq(CorpsDesc::getId, corpsDesc.getId());
-		lambdaQueryWrapper.eq(CorpsDesc::getTenantId, SecureUtil.getTenantId());
-		lambdaQueryWrapper.eq(CorpsDesc::getCorpType, corpsDesc.getCorpType());
-		if (!"234557".equals(AuthUtil.getTenantId())) {
+		lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted,0);
+		lambdaQueryWrapper.eq(CorpsDesc::getId,corpsDesc.getId());
+		lambdaQueryWrapper.eq(CorpsDesc::getTenantId,SecureUtil.getTenantId());
+		lambdaQueryWrapper.eq(CorpsDesc::getCorpType,corpsDesc.getCorpType());
+		if (!"234557".equals(AuthUtil.getTenantId())){
 			lambdaQueryWrapper.orderByAsc(CorpsDesc::getCname);
 		}
 		List<CorpsDesc> corpsDescList = corpsDescService.list(lambdaQueryWrapper);
@@ -740,9 +763,9 @@ public class CorpsDescController extends BladeController {
 						list.forEach(items -> {
 							R<User> user = userClient.userInfoById(Long.valueOf(items));
 							if (user.isSuccess() && user.getData() != null) {
-								Map<String, Object> map = new HashMap<>();
-								map.put("id", items);
-								map.put("cname", user.getData().getName());
+								Map<String,Object> map = new HashMap<>();
+								map.put("id",items);
+								map.put("cname",user.getData().getName());
 								mapList.add(map);
 							}
 						});
@@ -760,10 +783,10 @@ public class CorpsDescController extends BladeController {
 	public R<List<CorpsDescVO>> listAll(@RequestParam("corpType") String corpType) {
 		redisClient.basicData("corps");
 		QueryWrapper<CorpsDesc> queryWrapper = new QueryWrapper<>();
-		queryWrapper.eq("is_deleted", 0);
-		queryWrapper.eq("tenant_id", AuthUtil.getTenantId());
-		queryWrapper.apply(ObjectUtils.isNotNull(corpType), "find_in_set(corp_type,'" + corpType + "')");
-		if (!"234557".equals(AuthUtil.getTenantId())) {
+		queryWrapper.eq("is_deleted",0);
+		queryWrapper.eq("tenant_id",AuthUtil.getTenantId());
+		queryWrapper.apply(ObjectUtils.isNotNull(corpType),"find_in_set(corp_type,'"+corpType+"')");
+		if (!"234557".equals(AuthUtil.getTenantId())){
 			queryWrapper.orderByAsc("cname");
 		}
 		List<CorpsDesc> pages = corpsDescService.list(queryWrapper);
@@ -820,45 +843,4 @@ public class CorpsDescController extends BladeController {
 		return R.data(corpsDescList);
 	}
 
-	/**
-	 * 客户信息(海运)
-	 */
-	@GetMapping("/oceanCorpsList")
-	@ApiOperationSupport(order = 11)
-	@ApiOperation(value = "所有客户信息", notes = "获得客户信息")
-	public R<List<CorpsDesc>> oceanCorpsList(CorpsDescVO corpsDesc) {
-		if (ObjectUtils.isNotNull(corpsDesc.getCorpsTypeName())){
-			LambdaQueryWrapper<CorpsType> corpsTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
-			corpsTypeLambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
-			corpsTypeLambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
-			corpsTypeLambdaQueryWrapper.eq(CorpsType::getCname, corpsDesc.getCorpsTypeName());
-			CorpsType corpsType = corpsTypeService.getOne(corpsTypeLambdaQueryWrapper);
-
-			LambdaQueryWrapper<CorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-			lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted, 0);
-			lambdaQueryWrapper.eq(CorpsDesc::getTenantId, SecureUtil.getTenantId());
-			lambdaQueryWrapper.eq(CorpsDesc::getCorpType, "KH");
-
-			if (ObjectUtils.isNotNull(corpsType)) {
-				//获取客户类别对应的id
-				LambdaQueryWrapper<CorpsTypeDesc> typeDescLambdaQueryWrapper = new LambdaQueryWrapper<>();
-				typeDescLambdaQueryWrapper.eq(CorpsTypeDesc::getTenantId, SecureUtil.getTenantId());
-				typeDescLambdaQueryWrapper.eq(CorpsTypeDesc::getCorpTypeId, corpsType.getId());
-				List<CorpsTypeDesc> list = corpsTypeDescService.list(typeDescLambdaQueryWrapper);
-				if (CollectionUtils.isNotEmpty(list)) {
-					corpsDesc.setTypeList(list.stream().filter(e -> e.getCorpId() != null).map(CorpsTypeDesc::getCorpId).collect(Collectors.toList()));
-				}else{
-					return R.data(new ArrayList<>());
-				}
-				lambdaQueryWrapper.in(CollectionUtils.isNotEmpty(corpsDesc.getTypeList()), CorpsDesc::getId, corpsDesc.getTypeList());
-				List<CorpsDesc> corpsDescList = corpsDescService.list(lambdaQueryWrapper);
-				return R.data(corpsDescList);
-			} else {
-				return R.data(new ArrayList<>());
-			}
-		}else{
-			return R.data(new ArrayList<>());
-		}
-	}
-
 }

+ 6 - 0
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/feign/DeliveryClient.java

@@ -83,4 +83,10 @@ public class DeliveryClient implements IDeliveryClient{
 		return deliveryService.list(new QueryWrapper<Delivery>().like("bill_no",orderNo).eq("is_deleted",0).eq("tenant_id", SecureUtil.getTenantId()).eq("trade_type",tradeType).eq("bill_type",billType));
 
 	}
+
+	@Override
+	@GetMapping(GET_ORG_MESSAGE)
+	public List<Delivery> getOrgMessage(String orgOrderNo,String tradeType) {
+		return deliveryService.list(new QueryWrapper<Delivery>().eq("org_order_no",orgOrderNo).eq("is_deleted",0).eq("tenant_id", SecureUtil.getTenantId()).eq("trade_type",tradeType));
+	}
 }

+ 5 - 5
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/impl/DeliveryServiceImpl.java

@@ -799,7 +799,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 		}
 
 		Date date = new Date();
-		Order orderStatus = orderDescClient.getById(select.getOrgId());
+		Order orderStatus = orderDescClient.getById(select.getSrcId());
 		if("681169".equals(AuthUtil.getTenantId())){
 			delivery.setDeliveryStatus("已发货");
 			delivery.setFreightQuantity(select.getTotalQuantity());
@@ -808,7 +808,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 			baseMapper.updateById(delivery);
 
 			Order temp = new Order();
-			temp.setId(select.getOrgId());//销售主表id
+			temp.setId(select.getSrcId());//销售主表id
 			if (ObjectUtil.isNotEmpty(orderStatus.getReceivingStatus()) && "已收货".equals(orderStatus.getReceivingStatus())){
 				temp.setOrderStatus("已完成");
 			}
@@ -826,7 +826,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 			orderDescClient.updateOrder(temp);
 
 			Order orderTemp = new Order();
-			orderTemp.setId(select.getSrcId());//采购主表id
+			orderTemp.setId(select.getOrgId());//采购主表id
 			orderTemp.setOrderStatus("待收货");
 			orderTemp.setActualDeliveryDate(select.getBusinessDate());
 			if (select.getTotalQuantity().compareTo(BigDecimal.ZERO) == 0){
@@ -845,7 +845,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 			baseMapper.updateById(delivery);
 
 			Order temp = new Order();
-			temp.setId(select.getOrgId());
+			temp.setId(select.getOrgId());//采购主表id
 			temp.setOrderStatus("待发货");
 			temp.setActualDeliveryDate(select.getBusinessDate());
 			if (select.getTotalQuantity().compareTo(BigDecimal.ZERO) == 0){
@@ -857,7 +857,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 			orderDescClient.updateOrder(temp);
 
 			Order orderTemp = new Order();
-			orderTemp.setId(select.getSrcId());
+			orderTemp.setId(select.getSrcId());//销售主表id
 			orderTemp.setOrderStatus("已发货");
 			orderTemp.setActualDeliveryDate(select.getBusinessDate());
 			if (select.getTotalQuantity().compareTo(BigDecimal.ZERO) == 0){

+ 34 - 5
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/controller/OrderController.java

@@ -851,20 +851,49 @@ public class OrderController extends BladeController {
 	}
 
 	/**
-	 * 审批通过撤销审
+	 * 申请退单审批请
 	 */
-	@PostMapping("/checkPassCancel")
+	@PostMapping("/checkChargeBack")
+	@RepeatSubmit
+	public R checkChargeBack(@RequestBody Order order) {
+		orderService.checkChargeBack(order);
+		return R.data("操作成功");
+	}
+
+	/**
+	 * 申请退单审核中
+	 */
+	@PostMapping("/underChargeBackReview")
+	@ApiOperationSupport(order = 14)
+	@ApiOperation(value = "申请退单审核中", notes = "传入id")
+	public R underChargeBackReview(@ApiParam(value = "主表id", required = true) @RequestParam Long id) {
+		orderService.underChargeBackReview(id);
+		return R.success("操作成功");
+	}
+
+	/**
+	 * 申请退单审批通过
+	 */
+	@PostMapping("/checkRepealCancel")
 	@ApiOperationSupport(order = 12)
 	@ApiOperation(value = "审批通过撤销审核", notes = "传入id")
 	public R checkRepealCancel(@ApiParam(value = "主表id", required = true) @RequestParam Long id) {
-		if (id == null){
-			throw  new SecurityException("缺少必要的参数");
-		}
 		orderService.checkPassCancel(id);
 		return R.success("操作成功");
 	}
 
 	/**
+	 * 申请退单审核不通过
+	 */
+	@PostMapping("/passChargeBackCancel")
+	@ApiOperationSupport(order = 13)
+	@ApiOperation(value = "申请退单审核不通过", notes = "传入财务id")
+	public R passChargeBackCancel(@RequestParam Long id) {
+		orderService.passChargeBackCancel(id);
+		return R.success("操作成功");
+	}
+
+	/**
 	 * 特批审核通过
 	 */
 	@PostMapping("/passSpecialCheck")

+ 60 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/OrderStatisticsOneExcel.java

@@ -0,0 +1,60 @@
+package org.springblade.purchase.sales.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 统计分析 数量金额汇总明细,发货客户明细,发货规格明细导出统一实体类
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class OrderStatisticsOneExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 日期
+	 */
+	@ExcelProperty(value = "日期")
+	private Date createTime;
+
+	/**
+	 * 销售单号
+	 */
+	@ExcelProperty(value = "销售单号")
+	private String orderNo;
+
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "数量")
+	private Integer quantity;
+
+	/**
+	 * 金额
+	 */
+	@ExcelProperty(value = "金额")
+	private BigDecimal amount;
+
+	/**
+	 * 到货数量
+	 */
+	@ExcelProperty(value = "到货数量")
+	private BigDecimal actualQuantity;
+
+	/**
+	 * 到货金额
+	 */
+	@ExcelProperty(value = "到货金额")
+	private BigDecimal arrivalAmount;
+
+}

+ 77 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/OrderStatisticsThreeExcel.java

@@ -0,0 +1,77 @@
+package org.springblade.purchase.sales.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 统计分析 客户利润明细,业务员利润明细,品牌利润明细导出统一实体类
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class OrderStatisticsThreeExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 日期
+	 */
+	@ExcelProperty(value = "日期")
+	private Date createTime;
+
+	/**
+	 * 销售单号
+	 */
+	@ExcelProperty(value = "销售单号")
+	private String orderNo;
+
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "数量")
+	private Integer quantity;
+
+	/**
+	 * 金额
+	 */
+	@ExcelProperty(value = "金额")
+	private BigDecimal amount;
+
+	/**
+	 * 到货数量
+	 */
+	@ExcelProperty(value = "到货数量")
+	private BigDecimal actualQuantity;
+
+	/**
+	 * 到货金额
+	 */
+	@ExcelProperty(value = "到货金额")
+	private BigDecimal arrivalAmount;
+
+	/**
+	 * 返利
+	 */
+	@ExcelProperty(value = "返利")
+	private BigDecimal thisUsedProfit;
+
+	/**
+	 * 毛利额
+	 */
+	@ExcelProperty(value = "毛利额")
+	private BigDecimal netGrossProfit;
+
+	/**
+	 * 订单运费
+	 */
+	@ExcelProperty(value = "订单运费")
+	private BigDecimal predictOceanFreight;
+}

+ 65 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/OrderStatisticsTwoExcel.java

@@ -0,0 +1,65 @@
+package org.springblade.purchase.sales.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 统计分析 发货业务员明细导出实体类
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class OrderStatisticsTwoExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 日期
+	 */
+	@ExcelProperty(value = "日期")
+	private Date createTime;
+
+	/**
+	 * 销售单号
+	 */
+	@ExcelProperty(value = "销售单号")
+	private String orderNo;
+
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "数量")
+	private Integer quantity;
+
+	/**
+	 * 金额
+	 */
+	@ExcelProperty(value = "金额")
+	private BigDecimal amount;
+
+	/**
+	 * 到货数量
+	 */
+	@ExcelProperty(value = "到货数量")
+	private BigDecimal actualQuantity;
+
+	/**
+	 * 到货金额
+	 */
+	@ExcelProperty(value = "到货金额")
+	private BigDecimal arrivalAmount;
+
+	/**
+	 * 毛利额
+	 */
+	@ExcelProperty(value = "毛利额")
+	private BigDecimal grossProfit;
+}

+ 50 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/export/ExportOrderController.java

@@ -23,10 +23,12 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.deliver.goods.entity.Delivery;
 import org.springblade.deliver.goods.feign.IDeliveryClient;
+import org.springblade.finance.excel.PayExcel;
 import org.springblade.finance.feign.IFinanceClient;
 import org.springblade.finance.vojo.Acc;
 import org.springblade.purchase.sales.entity.Order;
@@ -1222,4 +1224,52 @@ public class ExportOrderController extends BladeController {
 			ExcelUtil.export(response, "数量金额汇总对比统计", "数量金额汇总对比统计", list, TotalSummaryExcel.class);
 		}
 	}
+
+	/**
+	 * 统计分析明细导出统一接口
+	 */
+	@GetMapping("/统计分析明细导出统一接口")
+	@ApiOperation(value = "统计分析明细导出统一接口", notes = "统计分析明细导出统一接口")
+	public void timeUnifiedExport(OrderStatisticsVo statisticsVo, HttpServletResponse response){
+		statisticsVo.setTenantId(SecureUtil.getTenantId());
+		List<OrderStatisticsVo> list = new ArrayList<>();
+
+		if ("totalSummaryItem".equals(statisticsVo.getIdentification())){//数据金额明细导出
+			list = orderService.totalSummaryItemExport(statisticsVo);
+			List<OrderStatisticsOneExcel> excelList = BeanUtil.copy(list, OrderStatisticsOneExcel.class);
+			if (ObjectUtil.isNotEmpty(statisticsVo.getYear())){
+				ExcelUtil.export(response, statisticsVo.getYear() + "年" + statisticsVo.getMonth() + "月数量金额汇总明细统计",
+					statisticsVo.getYear() + "年" + statisticsVo.getMonth() + "月数量金额汇总明细统计", excelList, OrderStatisticsOneExcel.class);
+			}else {
+				ExcelUtil.export(response, "数量金额汇总明细统计", "数量金额汇总明细统计", excelList, OrderStatisticsOneExcel.class);
+			}
+		}else if ("corpStatisticsItem".equals(statisticsVo.getIdentification())){//发货客户明细导出
+			list = orderService.corpStatisticsItemExport(statisticsVo);
+			List<OrderStatisticsOneExcel> excelList = BeanUtil.copy(list, OrderStatisticsOneExcel.class);
+			ExcelUtil.export(response, "发货客户明细统计", "发货客户明细统计", excelList, OrderStatisticsOneExcel.class);
+		}else if ("specificationsProfitItem".equals(statisticsVo.getIdentification())){//发货规格明细导出
+			list = orderService.specificationsProfitItemExport(statisticsVo);
+			List<OrderStatisticsOneExcel> excelList = BeanUtil.copy(list, OrderStatisticsOneExcel.class);
+			ExcelUtil.export(response, "发货规格明细统计", "发货客户明细统计", excelList, OrderStatisticsOneExcel.class);
+		}else if ("salesmanStatisticsItem".equals(statisticsVo.getIdentification())){//发货业务员明细导出
+			list = orderService.salesmanStatisticsItemExport(statisticsVo);
+			List<OrderStatisticsTwoExcel> excelList = BeanUtil.copy(list, OrderStatisticsTwoExcel.class);
+			ExcelUtil.export(response, "发货业务员明细统计", "发货客户明细统计", excelList, OrderStatisticsTwoExcel.class);
+		}else if ("customerProfitItem".equals(statisticsVo.getIdentification())){//客户利润明细导出
+			list = orderService.customerProfitItemExport(statisticsVo);
+			List<OrderStatisticsThreeExcel> excelList = BeanUtil.copy(list, OrderStatisticsThreeExcel.class);
+			ExcelUtil.export(response, "客户利润明细统计", "客户利润明细统计", excelList, OrderStatisticsThreeExcel.class);
+		}else if ("salesmanProfitItem".equals(statisticsVo.getIdentification())){//业务员利润明细导出
+			list = orderService.salesmanProfitItemExport(statisticsVo);
+			List<OrderStatisticsThreeExcel> excelList = BeanUtil.copy(list, OrderStatisticsThreeExcel.class);
+			ExcelUtil.export(response, "业务员利润明细统计", "业务员利润明细统计", excelList, OrderStatisticsThreeExcel.class);
+		}else if ("brandProfitItem".equals(statisticsVo.getIdentification())){//品牌利润明细导出
+			list = orderService.brandProfitItemExport(statisticsVo);
+			List<OrderStatisticsThreeExcel> excelList = BeanUtil.copy(list, OrderStatisticsThreeExcel.class);
+			ExcelUtil.export(response, "品牌利润明细统计", "品牌利润明细统计", excelList, OrderStatisticsThreeExcel.class);
+		}
+
+	}
+
+
 }

+ 20 - 11
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.xml

@@ -2739,7 +2739,7 @@ ORDER BY
                 </foreach>
             </if>
             <if test="totalSummaryVo.year !=null and totalSummaryVo.year != ''">
-                AND YEAR ( BO.create_time ) = #{totalSummaryVo.year}
+                AND YEAR ( BO.receipt_time ) = #{totalSummaryVo.year}
             </if>
             <if test="totalSummaryVo.status != null and totalSummaryVo.status != '' and totalSummaryVo.status == 0">
                 AND BO.receipt_time IS NOT NULL
@@ -2762,17 +2762,26 @@ ORDER BY
         business_order BO
         LEFT JOIN (
             SELECT
-                pid,
-                item_id,
-                IFNULL( sum( order_quantity ), 0 ) AS quantity,
-                IFNULL( sum( actual_quantity ), 0 ) AS actualQuantity,
-                IFNULL( SUM( actual_quantity * price ), 0 ) AS arrivalAmount
+                b.pid,
+                b.item_id,
+                IFNULL( sum( b.order_quantity ), 0 ) AS quantity,
+                IFNULL( sum( b.actual_quantity ), 0 ) AS actualQuantity,
+                IFNULL( sum( b.actual_quantity * b.price ), 0 ) AS arrivalAmount
             FROM
-                business_order_items
+                business_order_items b
+            LEFT JOIN basic_goods_desc BGD ON b.Item_id = BGD.id
             WHERE
-                is_deleted = 0
+                b.is_deleted = 0
+                AND b.tenant_id = '681169'
+                AND BGD.brand IS NOT NULL
+                <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                    and BGD.brand in
+                    <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
+                        '${item}'
+                    </foreach>
+                </if>
             GROUP BY
-            pid
+                b.pid
         ) BOI ON BOI.pid = BO.id
         LEFT JOIN basic_goods_desc BGD ON BOI.Item_id = BGD.id
         <where>
@@ -2787,7 +2796,7 @@ ORDER BY
                 </foreach>
             </if>
             <if test="statisticsVo.year !=null and statisticsVo.year != ''">
-                AND YEAR ( BO.create_time ) = #{statisticsVo.year}
+                AND YEAR ( BO.receipt_time ) = #{statisticsVo.year}
             </if>
             <if test="statisticsVo.month !=null and statisticsVo.month != ''">
                 AND IF
@@ -3176,7 +3185,7 @@ ORDER BY
                 </foreach>
             </if>
             <if test="totalSummaryVo.year !=null and totalSummaryVo.year != ''">
-                AND YEAR ( BO.create_time ) = #{totalSummaryVo.year}
+                AND YEAR ( BO.receipt_time ) = #{totalSummaryVo.year}
             </if>
             <if test="totalSummaryVo.status != null and totalSummaryVo.status != '' and totalSummaryVo.status == 0">
                 AND BO.receipt_time IS NOT NULL

+ 53 - 1
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/IOrderService.java

@@ -112,6 +112,8 @@ public interface IOrderService extends IService<Order> {
 
 	void checkOrder(Order order);
 
+
+
 	void passCheck(Long id);
 
 	void underReview(Long id);
@@ -119,10 +121,25 @@ public interface IOrderService extends IService<Order> {
 	void passCancel(Long id);
 
 	/**
-	 * 审批通过撤销审核
+	 * 申请退单审批请核
+	 */
+	void checkChargeBack(Order order);
+
+	/**
+	 * 申请退单审批中
+	 */
+	void underChargeBackReview(Long id);
+
+	/**
+	 * 申请退单审批通过
 	 */
 	void checkPassCancel(Long id);
 
+	/**
+	 * 申请退单审批不通过
+	 */
+	void passChargeBackCancel(Long id);
+
 	void passSpecialCheck(Long id);
 
 	void underSpecialReview(Long id);
@@ -287,6 +304,11 @@ public interface IOrderService extends IService<Order> {
 	List<CorpStatisticsExcel> corpStatisticsExport(OrderStatisticsVo statisticsVo);
 
 	/**
+	 * 发货客户明细导出
+	 */
+	List<OrderStatisticsVo> corpStatisticsItemExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 发货业务员统计
 	 */
 	IPage<OrderStatisticsVo> salesmanStatistics(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
@@ -302,6 +324,11 @@ public interface IOrderService extends IService<Order> {
 	List<SalesmanStatisticsExcel> salesmanStatisticsExport(OrderStatisticsVo statisticsVo);
 
 	/**
+	 * 发货业务员明细导出
+	 */
+	List<OrderStatisticsVo> salesmanStatisticsItemExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 业务员利润统计
 	 */
 	IPage<OrderStatisticsVo> salesmanProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
@@ -317,6 +344,11 @@ public interface IOrderService extends IService<Order> {
 	List<SalesmanProfitExcel> salesmanProfitExport(OrderStatisticsVo statisticsVo);
 
 	/**
+	 * 业务员利润明细导出
+	 */
+	List<OrderStatisticsVo> salesmanProfitItemExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 客户利润统计
 	 */
 	IPage<OrderStatisticsVo> customerProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
@@ -332,6 +364,11 @@ public interface IOrderService extends IService<Order> {
 	List<CustomerProfitExcel> customerProfitExport(OrderStatisticsVo statisticsVo);
 
 	/**
+	 * 客户利润明细导出
+	 */
+	List<OrderStatisticsVo> customerProfitItemExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 品牌利润对比统计
 	 */
 	IPage<OrderStatisticsVo> brandProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
@@ -347,6 +384,11 @@ public interface IOrderService extends IService<Order> {
 	List<BrandProfitExcel> brandProfitExport(OrderStatisticsVo statisticsVo);
 
 	/**
+	 * 品牌利润明细导出
+	 */
+	List<OrderStatisticsVo> brandProfitItemExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 发货规格统计
 	 */
 	IPage<OrderStatisticsVo> specificationsProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
@@ -362,6 +404,11 @@ public interface IOrderService extends IService<Order> {
 	List<SpecificationsProfitExcel> specificationsProfitExport(OrderStatisticsVo statisticsVo);
 
 	/**
+	 * 发货规格明细导出
+	 */
+	List<OrderStatisticsVo> specificationsProfitItemExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 数量金额汇总对比统计
 	 */
 	IPage<TotalSummaryVo> totalSummary(IPage<TotalSummaryVo> page, TotalSummaryVo totalSummaryVo);
@@ -377,6 +424,11 @@ public interface IOrderService extends IService<Order> {
 	List<TotalSummaryExcel> totalSummaryExport(TotalSummaryVo totalSummaryVo);
 
 	/**
+	 * 数量金额明细导出
+	 */
+	List<OrderStatisticsVo> totalSummaryItemExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 计算国内费用
 	 */
 	Map<String,Object> calculationDomesticFees(Order order);

+ 25 - 2
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/BidingAgentServiceImpl.java

@@ -15,8 +15,7 @@ import org.springblade.purchase.sales.mapper.BidingAgentMapper;
 import org.springblade.purchase.sales.service.IBidingAgentService;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * 标书代理信息表 服务实现类
@@ -38,6 +37,10 @@ public class BidingAgentServiceImpl extends ServiceImpl<BidingAgentMapper, Bidin
 	 * @return
 	 */
 	public List<BidingAgent> saveBidingAgentMassage(List<BidingAgent> list, Long pid) {
+		Boolean msg = knowledgeIsRepeat(list);
+		if (msg){
+			throw new SecurityException("代理重复,请检查代理信息");
+		}
 		list.forEach(item -> {
 			if (item.getId() == null){//id为空 新增
 				item.setTenantId(SecureUtil.getTenantId());
@@ -96,4 +99,24 @@ public class BidingAgentServiceImpl extends ServiceImpl<BidingAgentMapper, Bidin
 
 		return bidingAgent;
 	}
+
+	/**
+	 * 判断List<BidingAgent>的对象agentId是否有重复,有重复true
+	 *
+	 * @param list
+	 * @return
+	 */
+	private Boolean knowledgeIsRepeat(List<BidingAgent> list) {
+		Set<BidingAgent> set = new TreeSet<BidingAgent>(new Comparator<BidingAgent>() {
+			public int compare(BidingAgent a, BidingAgent b) {
+				// 字符串则按照asicc码升序排列
+				return a.getAgentId().compareTo(b.getAgentId());
+			}
+		});
+		set.addAll(list);
+		if (set.size() < list.size()) {
+			return true;
+		}
+		return false;
+	}
 }

+ 312 - 38
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java

@@ -52,13 +52,14 @@ import org.springblade.finance.vojo.Items;
 import org.springblade.finance.vojo.Settlement;
 import org.springblade.land.entity.LandOrder;
 import org.springblade.land.feign.ILandClient;
-import org.springblade.payment.tonglianPayment.fegin.IPaymentClient;
 import org.springblade.purchase.sales.entity.*;
 import org.springblade.purchase.sales.enums.OrderStatusEnum;
 import org.springblade.purchase.sales.excel.*;
 import org.springblade.purchase.sales.mapper.*;
 import org.springblade.purchase.sales.service.IOrderFilesService;
 import org.springblade.purchase.sales.service.IOrderService;
+import org.springblade.purchase.sales.tonglianPayment.utils.AnalysisMapUtils;
+import org.springblade.purchase.sales.tonglianPayment.utils.SybPayService;
 import org.springblade.purchase.sales.vo.*;
 import org.springblade.stock.entity.StockGoods;
 import org.springblade.stock.feign.IStockGoodsClient;
@@ -75,6 +76,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import javax.sql.rowset.serial.SerialException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.MathContext;
@@ -82,7 +84,6 @@ import java.math.RoundingMode;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 import static org.springblade.common.constant.TenantConstant.*;
 
@@ -148,7 +149,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
 	private final IRedisClient redisClient;//redis缓存处理
 
-	private final IPaymentClient paymentClient;//支付
+
+	private final ITongLianPaymentClient tongLianPaymentClient;//支付
 
 	/**
 	 * 库区信息
@@ -277,7 +279,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 				String[] arrs = order.getSrcOrderNo().split(",");
 				for (String arr : arrs) {
 					Order order1 = baseMapper.selectOne(new LambdaQueryWrapper<Order>().eq(Order::getSysNo, arr));
-					if (ObjectUtils.isNotNull(order1)) {
+					if (ObjectUtils.isNotNull(order1)){
 						order1.setSrcOrderNo(order.getSysNo());
 						baseMapper.updateById(order1);
 					}
@@ -1131,6 +1133,122 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
+	public void checkChargeBack(Order order) {
+		Order salesOrder = baseMapper.selectById(order.getId());
+
+		if (ObjectUtil.isEmpty(salesOrder)){//判断单据是否存在
+			throw new SecurityException("单据信息异常");
+		}
+
+		if (salesOrder.getChargebackStatus() == 1){
+			throw new SecurityException("订单已开启审核,请勿重复提交");
+		}
+
+		//根据销售订单id获得采购订单
+		Order orderPurchase = baseMapper.selectOne(new LambdaQueryWrapper<Order>()
+			.eq(Order::getIsDeleted, 0)
+			.eq(Order::getTenantId, AuthUtil.getTenantId())
+			.eq(Order::getSrcId, salesOrder.getId()));
+		if (ObjectUtil.isNotEmpty(orderPurchase)){//判断采购订单是否存在
+			throw new SecurityException("采购订单已存在,禁止撤销");
+		}
+
+		//根据订单号获得收发货
+		List<Delivery> deliveryList = deliveryClient.getOrgMessage(salesOrder.getOrderNo(), OrderTypeEnum.DOMESTIC.getType());
+		if (CollectionUtils.isNotEmpty(deliveryList)) {//判断收发货是否存在
+			throw new SecurityException("收发货单据已存在,禁止撤销");
+		}
+
+		//获得财务收款信息
+		List<Settlement> settlementList = financeClient.selectSrcOrderNo(salesOrder.getOrderNo());
+		if (CollectionUtils.isNotEmpty(settlementList)) {//判断收款是否存在
+			throw new SecurityException("收款单据已存在,禁止撤销");
+		}
+
+		//审批数据
+		AuditProecessDTO auditProecessDTO = new AuditProecessDTO();
+		//获取审批级次
+		List<AuditPathsLevels> auditPathsLevels = null;
+		// 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
+		AuditPathsActs pathsActs = null;
+		//是否开启流程
+		pathsActs = iCheckClient.getActsByActId(21, "status");
+		//获取审批信息
+		auditPathsLevels = iCheckClient.listLevelsByActId(21, "status");
+		auditProecessDTO.setTimes(1);
+
+		// 没开启审批流直接走 通过流程
+		if (pathsActs == null || pathsActs.getIsEnable() == 2) {
+			throw new SecurityException("当前租户未查询到审批流配置");
+		} else {
+
+			if (CollectionUtils.isEmpty(auditPathsLevels)) {
+				throw new SecurityException("开启审批失败:未查询到审批信息");
+			}
+
+			//增加审批类型
+			auditProecessDTO.setProcessType("退单审批");
+
+			LambdaQueryWrapper<OrderItems> orderItemsLambdaQueryWrapper = new LambdaQueryWrapper<>();
+			orderItemsLambdaQueryWrapper
+				.eq(OrderItems::getGoodType, 0)
+				.eq(OrderItems::getPid, salesOrder.getId())
+				.eq(OrderItems::getIsDeleted, 0);
+			List<OrderItems> orderItems = orderItemsMapper.selectList(orderItemsLambdaQueryWrapper);
+			if (CollectionUtils.isNotEmpty(orderItems)) {
+				auditProecessDTO.setOrderQuantity(orderItems.stream().map(OrderItems::getOrderQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				auditProecessDTO.setAmount(orderItems.stream().map(OrderItems::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+			} else {
+				auditProecessDTO.setOrderQuantity(BigDecimal.ZERO);
+				auditProecessDTO.setAmount(BigDecimal.ZERO);
+			}
+
+			// 绑定审核类型
+			auditProecessDTO.setCheckType("XSTD");//代理订单
+			// 追加跳转路由url
+			auditProecessDTO.setUrl(salesOrder.getUrl());
+			auditProecessDTO.setPageStatus(salesOrder.getPageStatus());
+			auditProecessDTO.setPageLabel(salesOrder.getPageLabel());
+			auditProecessDTO.setOrderRemark(salesOrder.getOrderRemark());//订单备注
+			auditProecessDTO.setPathsLevelsList(auditPathsLevels);
+			auditProecessDTO.setActId(1);
+			auditProecessDTO.setSrcBillId(salesOrder.getId());//申请表id
+			auditProecessDTO.setBillId(salesOrder.getId());//业务id
+			auditProecessDTO.setBillNo(salesOrder.getOrderNo());//业务编号
+			auditProecessDTO.setSendUserId(AuthUtil.getUserId());//请核人id
+			auditProecessDTO.setSendName(AuthUtil.getUserName());//请核人名称
+			auditProecessDTO.setSendTime(new Date());//请核时间
+			auditProecessDTO.setBillTime(salesOrder.getCreateTime());//业务日期
+			auditProecessDTO.setTenantId(AuthUtil.getTenantId());//租户id
+			R financeProcess = iCheckClient.createFinanceProcess(auditProecessDTO);
+			if (!financeProcess.isSuccess()) {
+				throw new SecurityException("操作失败,请联系管理员");
+			}
+		}
+
+		salesOrder.setChargebackStatus(1);
+		salesOrder.setChargebackUser(AuthUtil.getUserName());
+		salesOrder.setChargebackTime(new Date());
+		baseMapper.updateById(salesOrder);
+
+	}
+
+	/**
+	 * 申请退单审批中
+	 */
+	@Override
+	public void underChargeBackReview(Long id) {
+		Order order = baseMapper.selectById(id);
+		if (order == null) {
+			throw new SecurityException("审批失败");
+		}
+		order.setChargebackStatus(2);
+		baseMapper.updateById(order);
+	}
+
+	@Override
 	public void passCheck(Long id) {
 
 		// ===========================start 审核通过修改销售订单信息==========================
@@ -1365,31 +1483,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	public void checkPassCancel(Long id) {
 		//获得当前销售订单信息
 		Order orderMessage = baseMapper.selectById(id);
-		if (orderMessage == null) {//判断销售订单是否为null
+		if (orderMessage == null){//判断销售订单是否为null
 			throw new SecurityException("撤销失败");
 		}
 
-		//根据销售订单id获得采购订单
-		Order orderPurchase = baseMapper.selectOne(new LambdaQueryWrapper<Order>()
-			.eq(Order::getIsDeleted, 0)
-			.eq(Order::getTenantId, AuthUtil.getTenantId())
-			.eq(Order::getSrcId, orderMessage.getId()));
-		if (ObjectUtil.isNotEmpty(orderPurchase)) {//判断采购订单是否存在
-			throw new SecurityException("采购订单已存在,禁止撤销");
-		}
-
-		//根据订单号获得工厂发货
-		List<Delivery> deliveryList = deliveryClient.getOrderMessage(orderMessage.getOrderNo(), OrderTypeEnum.DOMESTIC.getType());
-		if (CollectionUtils.isNotEmpty(deliveryList)) {//判断收发货是否存在
-			throw new SecurityException("收发货单据已存在,禁止撤销");
-		}
-
-		//获得财务收款信息
-		List<Settlement> settlementList = financeClient.selectSrcOrderNo(orderMessage.getOrderNo());
-		if (CollectionUtils.isNotEmpty(settlementList)) {//判断收款是否存在
-			throw new SecurityException("收款单据已存在,禁止撤销");
-		}
-
 		// 销售释放库存
 		if ("XS".equals(orderMessage.getBillType()) && orderMessage.getTradeType().equals(OrderTypeEnum.DOMESTIC.getType())) {
 			// ===========================Start 审核撤销释放库存=============================
@@ -1438,7 +1535,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
 					//删除明细
 					int res = orderItemsMapper.deleteById(e.getId());
-					if (res != 1) {
+					if (res != 1){
 						throw new SecurityException("撤销失败,明细错误");
 					}
 				});
@@ -1513,6 +1610,23 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
 	}
 
+	/**
+	 * 申请退单审批不通过
+	 */
+	@Override
+	public void passChargeBackCancel(Long id) {
+		Order order = baseMapper.selectById(id);
+		if (order == null) {
+			throw new SecurityException("审批失败");
+		}
+		baseMapper.update(null, new LambdaUpdateWrapper<Order>()
+			.set(Order::getChargebackStatus, 0)
+			.set(Order::getChargebackUser, null)
+			.set(Order::getChargebackTime, null)
+			.eq(Order::getId, id)
+		);
+	}
+
 	@Override
 	public void passSpecialCheck(Long id) {
 		Order order = baseMapper.selectById(id);
@@ -1903,6 +2017,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 发货客户明细导出
+	 */
+	@Override
+	public List<OrderStatisticsVo> corpStatisticsItemExport(OrderStatisticsVo statisticsVo) {
+		return baseMapper.corpStatisticsItem(null, statisticsVo, statisticsVo.getBrand(), statisticsVo.getChargeMember());
+	}
+
+	/**
 	 * 发货业务员统计
 	 */
 	@Override
@@ -1927,6 +2049,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 发货业务员明细导出
+	 */
+	@Override
+	public List<OrderStatisticsVo> salesmanStatisticsItemExport(OrderStatisticsVo statisticsVo) {
+		return baseMapper.salesmanStatisticsItem(null, statisticsVo, statisticsVo.getBrand(), statisticsVo.getChargeMember());
+	}
+
+	/**
 	 * 业务员利润统计
 	 */
 	@Override
@@ -1951,6 +2081,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 业务员利润明细导出
+	 */
+	@Override
+	public List<OrderStatisticsVo> salesmanProfitItemExport(OrderStatisticsVo statisticsVo) {
+		return baseMapper.salesmanProfitItem(null, statisticsVo, statisticsVo.getBrand(), statisticsVo.getChargeMember());
+	}
+
+	/**
 	 * 客户利润统计
 	 */
 	@Override
@@ -1975,6 +2113,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 客户利润明细导出
+	 */
+	@Override
+	public List<OrderStatisticsVo> customerProfitItemExport(OrderStatisticsVo statisticsVo) {
+		return baseMapper.customerProfitItem(null, statisticsVo, statisticsVo.getBrand());
+	}
+
+	/**
 	 * 品牌利润对比统计
 	 */
 	@Override
@@ -1999,6 +2145,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 品牌利润对比明细导出
+	 */
+	@Override
+	public List<OrderStatisticsVo> brandProfitItemExport(OrderStatisticsVo statisticsVo) {
+		return baseMapper.brandProfitItem(null, statisticsVo, statisticsVo.getBrand());
+	}
+
+	/**
 	 * 发货规格统计
 	 */
 	@Override
@@ -2023,6 +2177,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 发货规格明细导出
+	 */
+	@Override
+	public List<OrderStatisticsVo> specificationsProfitItemExport(OrderStatisticsVo statisticsVo) {
+		return baseMapper.specificationsProfitItem(null, statisticsVo, statisticsVo.getBrand(), statisticsVo.getChargeMember());
+	}
+
+	/**
 	 * 数量金额汇总对比统计
 	 */
 	@Override
@@ -2047,6 +2209,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 数量金额汇总对比统计导出
+	 */
+	@Override
+	public List<OrderStatisticsVo> totalSummaryItemExport(OrderStatisticsVo statisticsVo) {
+		return baseMapper.totalSummaryItem(null, statisticsVo, statisticsVo.getBrand());
+	}
+
+	/**
 	 * 计算国内费用
 	 *
 	 * @param order
@@ -2412,15 +2582,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	@Override
 	public R collectPayment(Order order) {
 		if ("线上".equals(order.getOrderSource())) {
+			R r = this.payPrepay(order.getId());
+			if (!r.isSuccess() || r.getCode() != 200) {
+				throw new RuntimeException("支付失败!原因:" + r.getData());
+			}
 			order.setStatus(2);
 			Order selectOrder = baseMapper.selectById(order.getId());
-
-			if (null == selectOrder) {
-				throw new RuntimeException("未找到订单信息,订单已取消");
-			}
-			if (selectOrder.getActualPaymentStatus() > 0) {
-				throw new RuntimeException("订单已支付,请不要重复操作");
-			}
 			if (ObjectUtils.isNotNull(selectOrder) && ObjectUtils.isNotNull(selectOrder.getDebitAmount())) {
 				List<Settlement> settlementList = new ArrayList<>();
 				Settlement settlement = new Settlement();
@@ -3939,10 +4106,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 							}
 						}
 					}
-					//箱号拼接字符串
-					List<Long> itemList = order.getOrderItemsList().stream().map(OrderItems::getItemId).distinct().collect(Collectors.toList());
-					order.setItemList(itemList);
-					return paymentClient.getWeChatPayment(order);
 				}
 			}
 		}
@@ -4108,6 +4271,117 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	@Override
+	public R payPrepay(Long orderId) {
+		//查询订单及物流信息
+		Order orderInfo = baseMapper.selectById(orderId);
+
+		if (null == orderInfo) {
+			throw new RuntimeException("未找到订单信息,订单已取消");
+		}
+
+		if (orderInfo.getActualPaymentStatus() > 0) {
+			throw new RuntimeException("订单已支付,请不要重复操作");
+		}
+
+		Parameters parameters = tongLianPaymentClient.getParametersOne();
+
+		if (ObjectUtils.isNull(parameters)) {
+			throw new RuntimeException("未找到支付信息");
+		}
+
+		R<User> r = userClient.userInfoById(AuthUtil.getUserId());
+		if (r.isSuccess() && ObjectUtils.isNull(r.getData())) {
+			throw new RuntimeException("未找到用户信息");
+		}
+
+
+		SybPayService service = new SybPayService();
+		//https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=3
+		Map<Object, Object> resultObj = new TreeMap();
+		//"https://test.allinpaygd.com/JWeb/NotifyServlet"
+		try {
+			// body 订单标题
+			LambdaQueryWrapper<OrderItems> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+			lambdaQueryWrapper.eq(OrderItems::getIsDeleted, 0).eq(OrderItems::getTenantId, AuthUtil.getTenantId()).eq(OrderItems::getPid, orderId);
+			//订单的商品nideshop_order_goods表
+			List<OrderItems> orderGoods = orderItemsMapper.selectList(lambdaQueryWrapper);
+			String body = "商品-";
+			if (null != orderGoods) {
+				for (OrderItems goodsVo : orderGoods) {
+					GoodsDesc goodsDesc = goodsDescClient.getGoodsDescDetail(goodsVo.getItemId());
+					if (ObjectUtils.isNotNull(goodsDesc)) {
+						body = body + goodsDesc.getCname() + "、";
+					}
+				}
+				if (body.length() > 0) {
+					body = body.substring(0, body.length() - 1);
+				}
+			}
+			Map<String, String> map = service.pay(orderInfo.getDebitAmount().multiply(new BigDecimal(100)).intValue(),
+				orderInfo.getSysNo(),
+				parameters.getPayType(),
+				body,
+				"",
+				r.getData().getOpenId(),
+				parameters.getValidtime(),
+				parameters.getNotifyUrl() + "/api/blade-purchase-sales/tongLianPayment/notify",
+				"",
+				"",
+				"",
+				"",
+				parameters.getSubAppid(),
+				"",
+				"",
+				"",
+				"",
+				"",
+				parameters.getCusIp(),
+				"");
+			print(map);
+
+			Map<String, String> mapType = null;
+			if (map != null) {
+				for (Object key : map.keySet()) {
+					if (key.equals("payinfo")) {
+						mapType = JSON.parseObject((String) map.get(key), Map.class);
+					}
+				}
+			}
+			// print(map);
+			if (map == null) {
+				throw new Exception("返回数据错误");
+			}
+			String return_code = AnalysisMapUtils.getString("retcode", map);
+			String return_msg = AnalysisMapUtils.getString("retmsg", map);
+			if (return_code.equalsIgnoreCase("FAIL")) {
+				throw new RuntimeException("支付失败," + return_msg);
+			} else if (return_code.equalsIgnoreCase("SUCCESS")) {
+				// 返回数据
+				String prepay_id = AnalysisMapUtils.getString("prepay_id", mapType);
+				// 先生成paySign 参考https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5
+				resultObj.put("appId", AnalysisMapUtils.getString("appId", mapType));
+				resultObj.put("timeStamp", AnalysisMapUtils.getString("timeStamp", mapType));
+				resultObj.put("nonceStr", AnalysisMapUtils.getString("nonceStr", mapType));
+				resultObj.put("package", AnalysisMapUtils.getString("package", mapType));
+				resultObj.put("signType", AnalysisMapUtils.getString("signType", mapType));
+				String paySign = AnalysisMapUtils.getString("paySign", mapType);
+				resultObj.put("paySign", paySign);
+				// 业务处理
+				orderInfo.setPrepayId(prepay_id);
+				// 付款中
+				orderInfo.setActualPaymentStatus(1);
+				//更新订单表
+				baseMapper.updateById(orderInfo);
+				return R.data(resultObj);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new RuntimeException("下单失败,error=" + e.getMessage());
+		}
+		return R.data("下单失败");
+	}
+
+	@Override
 	public R personalInformation(String tenantId) {
 		Map<String, Object> map = new HashMap<>();
 		if (StringUtils.isBlank(tenantId)) {

+ 43 - 41
blade-service/trade-finance/src/main/java/org/springblade/finance/mapper/AccMapper.xml

@@ -69,54 +69,56 @@
         IFNULL( BC.amount, 0 ) AS amount,
         IFNULL( FS.settlementAmount, 0 ) AS settlementAmount,
         IFNULL( IFNULL( BC.amount, 0 ) - IFNULL( FS.settlementAmount, 0 ), 0 ) AS balance,
-        IFNULL( BO.in_overpayment, 0 ) AS inOverpayment,
+        IFNULL( FS.caseOverPayment, 0 ) AS caseOverPayment,
+        IFNULL( BO.balance_overpaymen, 0 ) AS inOverpayment,
         BCD.opening_amount AS openingAmount
         FROM finance_acc FC
         LEFT JOIN basic_corps_desc BCD ON BCD.id = FC.Corpid
         LEFT JOIN business_overpayment BO ON BO.corp_id = FC.Corpid
         LEFT JOIN (
-        SELECT
-        FC.Corpid AS corpId,
-        SUM( FC.Amount ) AS amount
-        FROM finance_acc FC
-        <where>
-            FC.tenant_id = #{acc.tenantId}
-            and FC.is_deleted = 0
-            and FC.bill_type = #{acc.billType}
-            <if test='acc.createDateList != null and acc.createDateList[0] != null and acc.createDateList[0]!= ""'>
-                and FC.create_time &gt;= #{acc.createDateList[0]}
-            </if>
-            <if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
-                and FC.create_time &lt;= #{acc.createDateList[1]}
-            </if>
-        </where>
-        GROUP BY
-        FC.Corpid
+            SELECT
+                FC.Corpid AS corpId,
+                SUM( FC.Amount ) AS amount
+            FROM finance_acc FC
+            <where>
+                FC.tenant_id = #{acc.tenantId}
+                and FC.is_deleted = 0
+                and FC.bill_type = #{acc.billType}
+                <if test='acc.createDateList != null and acc.createDateList[0] != null and acc.createDateList[0]!= ""'>
+                    and FC.create_time &gt;= #{acc.createDateList[0]}
+                </if>
+                <if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
+                    and FC.create_time &lt;= #{acc.createDateList[1]}
+                </if>
+            </where>
+            GROUP BY
+            FC.Corpid
         ) BC ON BC.corpId = FC.Corpid
         LEFT JOIN (
-        SELECT
-        FS.Corp_id AS corpId,
-        sum( FS.Amount ) AS settlementAmount
-        FROM finance_settlement FS
-        <where>
-            FS.tenant_id = #{acc.tenantId}
-            AND FS.is_deleted = 0
-            AND FS.finance_status = '结算完成'
-            <if test='acc.billType != null and acc.billType != "" and acc.billType == "申请"'>
-                AND FS.bill_type = '付费'
-            </if>
-            <if test='acc.billType != null and acc.billType != "" and acc.billType == "收费"'>
-                AND FS.bill_type = #{acc.billType}
-            </if>
-            <if test='acc.createDateList != null and acc.createDateList[0] != null and acc.createDateList[0]!= ""'>
-                and FS.completion_time &gt;= #{acc.createDateList[0]}
-            </if>
-            <if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
-                and FS.completion_time &lt;= #{acc.createDateList[1]}
-            </if>
-        </where>
-        GROUP BY
-        FS.Corp_id
+            SELECT
+                FS.Corp_id AS corpId,
+                sum( FS.Amount ) AS settlementAmount,
+                sum( case_over_payment ) AS caseOverPayment
+            FROM finance_settlement FS
+            <where>
+                FS.tenant_id = #{acc.tenantId}
+                AND FS.is_deleted = 0
+                AND FS.finance_status = '结算完成'
+                <if test='acc.billType != null and acc.billType != "" and acc.billType == "申请"'>
+                    AND FS.bill_type = '付费'
+                </if>
+                <if test='acc.billType != null and acc.billType != "" and acc.billType == "收费"'>
+                    AND FS.bill_type = #{acc.billType}
+                </if>
+                <if test='acc.createDateList != null and acc.createDateList[0] != null and acc.createDateList[0]!= ""'>
+                    and FS.completion_time &gt;= #{acc.createDateList[0]}
+                </if>
+                <if test='acc.createDateList != null and acc.createDateList[1] != null and acc.createDateList[1]!= ""'>
+                    and FS.completion_time &lt;= #{acc.createDateList[1]}
+                </if>
+            </where>
+            GROUP BY
+            FS.Corp_id
         ) FS ON FS.corpId = FC.Corpid
         <where>
             FC.tenant_id = #{acc.tenantId}

+ 3 - 1
blade-service/trade-finance/src/main/java/org/springblade/finance/service/impl/SettlementServiceImpl.java

@@ -1339,7 +1339,9 @@ public class SettlementServiceImpl extends ServiceImpl<SettlementMapper, Settlem
 				sysOrderNo = sysOrderNo.append(items.getSrcOrderno()).append(",");
 			}
 		}
-		model.setSrcOrderno(sysOrderNo.substring(0, sysOrderNo.toString().length() - 1));
+		if (ObjectUtil.isNotEmpty(sysOrderNo)){
+			model.setSrcOrderno(sysOrderNo.substring(0, sysOrderNo.toString().length() - 1));
+		}
 
 		model.setForeignAmount(foreignTotal);
 		// todo 暂定用租户判断 国内贸易 收费 人民币金额 可以手输