Ver Fonte

2022年10月25日18:01:53

纪新园 há 3 anos atrás
pai
commit
d507dbb01c
20 ficheiros alterados com 778 adições e 142 exclusões
  1. 145 59
      blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java
  2. 161 0
      blade-auth/src/main/java/org/springblade/auth/utils/ImgVerifyCode.java
  3. 57 0
      blade-auth/src/main/java/org/springblade/auth/verification/verificationController.java
  4. 44 0
      blade-service-api/blade-client-api/src/main/java/org/springblade/client/dto/CorpsDescDto.java
  5. 6 0
      blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/CorpsAddr.java
  6. 22 0
      blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/CorpsDesc.java
  7. 11 15
      blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java
  8. 14 0
      blade-service/blade-client/src/main/java/org/springblade/client/common/controller/CommonFileController.java
  9. 12 0
      blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescPartsController.java
  10. 1 1
      blade-service/blade-client/src/main/java/org/springblade/client/corps/mapper/CorpsDescMapper.java
  11. 7 0
      blade-service/blade-client/src/main/java/org/springblade/client/corps/service/ICorpsDescService.java
  12. 96 29
      blade-service/blade-client/src/main/java/org/springblade/client/corps/service/impl/CorpsDescServiceImpl.java
  13. 3 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.java
  14. 13 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.xml
  15. 103 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/partsapp/AppPartsController.java
  16. 8 0
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/IOrderService.java
  17. 44 5
      blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java
  18. 17 24
      blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java
  19. 8 3
      blade-service/trade-purchase/src/main/java/com/trade/purchase/order/service/impl/OrderItemsServiceImpl.java
  20. 6 6
      blade-service/trade-purchase/src/main/java/com/trade/purchase/order/service/impl/OrderServiceImpl.java

+ 145 - 59
blade-auth/src/main/java/org/springblade/auth/service/BladeUserDetailsServiceImpl.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.auth.service;
 
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import org.apache.commons.lang.StringUtils;
@@ -69,78 +70,163 @@ public class BladeUserDetailsServiceImpl implements UserDetailsService {
 		String paramTenant = request.getParameter(TokenUtil.TENANT_PARAM_KEY);
 		String password = request.getParameter(TokenUtil.PASSWORD_KEY);
 		String grantType = request.getParameter(TokenUtil.GRANT_TYPE_KEY);
-		if (StringUtil.isAllBlank(headerTenant, paramTenant)) {
-			throw new UserDeniedAuthorizationException(TokenUtil.TENANT_NOT_FOUND);
-		}
-		String tenantId = StringUtils.isBlank(headerTenant) ? paramTenant : headerTenant;
 
-		// 判断登录是否锁定
-		// TODO 2.8.3版本将增加:1.参数管理读取配置 2.用户管理增加解封按钮
-		int count = getFailCount(tenantId, username);
-		if (count >= FAIL_COUNT) {
+		//判断租户号是否为空  为空查询数据库赋值
+		if (ObjectUtils.isNull(headerTenant) && ObjectUtils.isNull(paramTenant)) {
+			User user = new User();
+			user = userClient.loginByAccount(username, null);
+			if (ObjectUtils.isNull(user)) {
+				user = userClient.loginByAccount(null, username);
+				if (ObjectUtils.isNull(user)) {
+					throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
+				}
+			}
+			headerTenant = user.getTenantId();
+			paramTenant = user.getTenantId();
+			String tenantId = StringUtils.isBlank(headerTenant) ? paramTenant : headerTenant;
+
+			// 判断登录是否锁定
+			// TODO 2.8.3版本将增加:1.参数管理读取配置 2.用户管理增加解封按钮
+			int count = getFailCount(tenantId, user.getAccount());
+			if (count >= FAIL_COUNT) {
 //			throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_TOO_MANY_FAILS);
-		}
+			}
 
-		// 获取租户信息
-		R<Tenant> tenant = sysClient.getTenant(tenantId);
-		if (tenant.isSuccess()) {
-			if (TokenUtil.judgeTenant(tenant.getData())) {
-				throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT_PERMISSION);
+			// 获取租户信息
+			R<Tenant> tenant = sysClient.getTenant(tenantId);
+			if (tenant.isSuccess()) {
+				if (TokenUtil.judgeTenant(tenant.getData())) {
+					throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT_PERMISSION);
+				}
+			} else {
+				throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT);
 			}
-		} else {
-			throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT);
-		}
 
-		// 获取用户类型
-		String userType = Func.toStr(request.getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE);
+			// 获取用户类型
+			String userType = Func.toStr(request.getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE);
 
-		// 远程调用返回数据
-		R<UserInfo> result;
-		// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
-		if (userType.equals(UserEnum.WEB.getName())) {
-			result = userClient.userInfo(tenantId, username, UserEnum.WEB.getName());
-		} else if (userType.equals(UserEnum.APP.getName())) {
-			result = userClient.userInfo(tenantId, username, UserEnum.APP.getName());
-		} else {
-			result = userClient.userInfo(tenantId, username, UserEnum.OTHER.getName());
-		}
+			// 远程调用返回数据
+			R<UserInfo> result;
+			// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
+			if (userType.equals(UserEnum.WEB.getName())) {
+				result = userClient.userInfo(tenantId, user.getAccount(), UserEnum.WEB.getName());
+			} else if (userType.equals(UserEnum.APP.getName())) {
+				result = userClient.userInfo(tenantId, user.getAccount(), UserEnum.APP.getName());
+			} else {
+				result = userClient.userInfo(tenantId, user.getAccount(), UserEnum.OTHER.getName());
+			}
 
-		// 判断返回信息
-		if (result.isSuccess()) {
-			UserInfo userInfo = result.getData();
-			User user = userInfo.getUser();
-			// 用户不存在,但提示用户名与密码错误并锁定账号
-			if (user == null || user.getId() == null) {
-				setFailCount(tenantId, username, count);
-				throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
+			// 判断返回信息
+			if (result.isSuccess()) {
+				UserInfo userInfo = result.getData();
+				User user1 = userInfo.getUser();
+				// 用户不存在,但提示用户名与密码错误并锁定账号
+				if (user1 == null || user1.getId() == null) {
+					setFailCount(tenantId, user1.getAccount(), count);
+					throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
+				}
+				// 用户存在但密码错误,超过次数则锁定账号
+				if (!grantType.equals(TokenUtil.REFRESH_TOKEN_KEY) && !user1.getPassword().equals(DigestUtil.hex(password))) {
+					setFailCount(tenantId, user1.getAccount(), count);
+					throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
+				}
+				// 用户角色不存在
+				if (Func.isEmpty(userInfo.getRoles())) {
+					throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_ROLE);
+				}
+				// 多部门情况下指定单部门
+				if (Func.isNotEmpty(headerDept) && user1.getDeptId().contains(headerDept)) {
+					user1.setDeptId(headerDept);
+				}
+				// 多角色情况下指定单角色
+				if (Func.isNotEmpty(headerRole) && user1.getRoleId().contains(headerRole)) {
+					R<List<String>> roleResult = sysClient.getRoleAliases(headerRole);
+					if (roleResult.isSuccess()) {
+						userInfo.setRoles(roleResult.getData());
+					}
+					user1.setRoleId(headerRole);
+				}
+				return new BladeUserDetails(user1.getId(),
+					user1.getTenantId(), StringPool.EMPTY, user1.getName(), user1.getRealName(), user1.getDeptId(), user1.getPostId(), user1.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user1.getAvatar(), TokenUtil.DEFAULT_AVATAR),
+					user1.getAccount(), AuthConstant.ENCRYPT + user1.getPassword(), userInfo.getDetail(), true, true, true, true,
+					AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())));
+			} else {
+				throw new UsernameNotFoundException(result.getMsg());
 			}
-			// 用户存在但密码错误,超过次数则锁定账号
-			if (!grantType.equals(TokenUtil.REFRESH_TOKEN_KEY) && !user.getPassword().equals(DigestUtil.hex(password))) {
-				setFailCount(tenantId, username, count);
-				throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
+		} else {
+			if (StringUtil.isAllBlank(headerTenant, paramTenant)) {
+				throw new UserDeniedAuthorizationException(TokenUtil.TENANT_NOT_FOUND);
 			}
-			// 用户角色不存在
-			if (Func.isEmpty(userInfo.getRoles())) {
-				throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_ROLE);
+			String tenantId = StringUtils.isBlank(headerTenant) ? paramTenant : headerTenant;
+
+			// 判断登录是否锁定
+			// TODO 2.8.3版本将增加:1.参数管理读取配置 2.用户管理增加解封按钮
+			int count = getFailCount(tenantId, username);
+			if (count >= FAIL_COUNT) {
+//			throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_TOO_MANY_FAILS);
 			}
-			// 多部门情况下指定单部门
-			if (Func.isNotEmpty(headerDept) && user.getDeptId().contains(headerDept)) {
-				user.setDeptId(headerDept);
+
+			// 获取租户信息
+			R<Tenant> tenant = sysClient.getTenant(tenantId);
+			if (tenant.isSuccess()) {
+				if (TokenUtil.judgeTenant(tenant.getData())) {
+					throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT_PERMISSION);
+				}
+			} else {
+				throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT);
 			}
-			// 多角色情况下指定单角色
-			if (Func.isNotEmpty(headerRole) && user.getRoleId().contains(headerRole)) {
-				R<List<String>> roleResult = sysClient.getRoleAliases(headerRole);
-				if (roleResult.isSuccess()) {
-					userInfo.setRoles(roleResult.getData());
+
+			// 获取用户类型
+			String userType = Func.toStr(request.getHeader(TokenUtil.USER_TYPE_HEADER_KEY), TokenUtil.DEFAULT_USER_TYPE);
+
+			// 远程调用返回数据
+			R<UserInfo> result;
+			// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
+			if (userType.equals(UserEnum.WEB.getName())) {
+				result = userClient.userInfo(tenantId, username, UserEnum.WEB.getName());
+			} else if (userType.equals(UserEnum.APP.getName())) {
+				result = userClient.userInfo(tenantId, username, UserEnum.APP.getName());
+			} else {
+				result = userClient.userInfo(tenantId, username, UserEnum.OTHER.getName());
+			}
+
+			// 判断返回信息
+			if (result.isSuccess()) {
+				UserInfo userInfo = result.getData();
+				User user = userInfo.getUser();
+				// 用户不存在,但提示用户名与密码错误并锁定账号
+				if (user == null || user.getId() == null) {
+					setFailCount(tenantId, username, count);
+					throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
+				}
+				// 用户存在但密码错误,超过次数则锁定账号
+				if (!grantType.equals(TokenUtil.REFRESH_TOKEN_KEY) && !user.getPassword().equals(DigestUtil.hex(password))) {
+					setFailCount(tenantId, username, count);
+					throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND);
+				}
+				// 用户角色不存在
+				if (Func.isEmpty(userInfo.getRoles())) {
+					throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_ROLE);
 				}
-				user.setRoleId(headerRole);
+				// 多部门情况下指定单部门
+				if (Func.isNotEmpty(headerDept) && user.getDeptId().contains(headerDept)) {
+					user.setDeptId(headerDept);
+				}
+				// 多角色情况下指定单角色
+				if (Func.isNotEmpty(headerRole) && user.getRoleId().contains(headerRole)) {
+					R<List<String>> roleResult = sysClient.getRoleAliases(headerRole);
+					if (roleResult.isSuccess()) {
+						userInfo.setRoles(roleResult.getData());
+					}
+					user.setRoleId(headerRole);
+				}
+				return new BladeUserDetails(user.getId(),
+					user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR),
+					username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(), true, true, true, true,
+					AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())));
+			} else {
+				throw new UsernameNotFoundException(result.getMsg());
 			}
-			return new BladeUserDetails(user.getId(),
-				user.getTenantId(), StringPool.EMPTY, user.getName(), user.getRealName(), user.getDeptId(), user.getPostId(), user.getRoleId(), Func.join(userInfo.getRoles()), Func.toStr(user.getAvatar(), TokenUtil.DEFAULT_AVATAR),
-				username, AuthConstant.ENCRYPT + user.getPassword(), userInfo.getDetail(), true, true, true, true,
-				AuthorityUtils.commaSeparatedStringToAuthorityList(Func.join(result.getData().getRoles())));
-		} else {
-			throw new UsernameNotFoundException(result.getMsg());
 		}
 	}
 

+ 161 - 0
blade-auth/src/main/java/org/springblade/auth/utils/ImgVerifyCode.java

@@ -0,0 +1,161 @@
+package org.springblade.auth.utils;
+
+import sun.misc.BASE64Encoder;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Random;
+
+public class ImgVerifyCode {
+
+	/**
+	 * 验证码图片的长
+	 */
+	private final int weight = 100;
+	/**
+	 * 验证码图片的宽
+	 */
+	private final int height = 40;
+	/**
+	 * 获取随机数对象
+	 */
+	private final Random r = new Random();
+	/**
+	 * 字体数组 {"宋体", "华文楷体", "黑体", "微软雅黑", "楷体_GB2312"};
+	 */
+	private final String[] fontNames = {"Georgia"};
+	/**
+	 * 用来保存验证码的文本内容
+	 */
+	private String text;
+
+	/**
+	 * 将验证码图片写出的方法
+	 * @param image
+	 * @param out
+	 * @throws IOException
+	 */
+	public static void output(BufferedImage image, OutputStream out) throws IOException {
+		ImageIO.write(image, "jpg", out);
+	}
+
+	/**
+	 * 获取随机的颜色
+	 *
+	 * @return
+	 */
+	private Color randomColor() {
+		//这里为什么是225,因为当r,g,b都为255时,即为白色,为了好辨认,需要颜色深一点。
+		int r = this.r.nextInt(225);
+		int g = this.r.nextInt(225);
+		int b = this.r.nextInt(225);
+		//返回一个随机颜色
+		return new Color(r, g, b);
+	}
+
+	/**
+	 * 获取随机字体
+	 *
+	 * @return
+	 */
+	private Font randomFont() {
+		//获取随机的字体
+		int index = r.nextInt(fontNames.length);
+		String fontName = fontNames[index];
+		//随机获取字体的样式,0是无样式,1是加粗,2是斜体,3是加粗加斜体
+		int style = r.nextInt(4);
+		//随机获取字体的大小
+		int size = r.nextInt(10) + 24;
+		//返回一个随机的字体
+		return new Font(fontName, style, size);
+	}
+
+	/**
+	 * 获取随机字符
+	 *
+	 * @return
+	 */
+	private char randomChar() {
+		//验证码数组
+		String codes = "23456789abcdefghjkmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ";
+		int index = r.nextInt(codes.length());
+		return codes.charAt(index);
+	}
+
+	/**
+	 * 画干扰线,验证码干扰线用来防止计算机解析图片
+	 *
+	 * @param image
+	 */
+	private void drawLine(BufferedImage image) {
+		//定义干扰线的数量
+		int num = r.nextInt(10);
+		Graphics2D g = (Graphics2D) image.getGraphics();
+		for (int i = 0; i < num; i++) {
+			int x1 = r.nextInt(weight);
+			int y1 = r.nextInt(height);
+			int x2 = r.nextInt(weight);
+			int y2 = r.nextInt(height);
+			g.setColor(randomColor());
+			g.drawLine(x1, y1, x2, y2);
+		}
+	}
+
+	/**
+	 * 创建图片的方法
+	 *
+	 * @return
+	 */
+	private BufferedImage createImage() {
+		//创建图片缓冲区
+		BufferedImage image = new BufferedImage(weight, height, BufferedImage.TYPE_INT_RGB);
+		//获取画笔
+		Graphics2D g = (Graphics2D) image.getGraphics();
+		//设置背景色随机
+		g.setColor(new Color(255, 255, r.nextInt(245) + 10));
+		g.fillRect(0, 0, weight, height);
+		//返回一个图片
+		return image;
+	}
+
+	/**
+	 * 获取验证码图片的方法
+	 *
+	 * @return
+	 */
+	public BufferedImage getImage() {
+		BufferedImage image = createImage();
+		//获取画笔
+		Graphics2D g = (Graphics2D) image.getGraphics();
+		StringBuilder sb = new StringBuilder();
+		//画四个字符即可
+		for (int i = 0; i < 4; i++) {
+			//随机生成字符,因为只有画字符串的方法,没有画字符的方法,所以需要将字符变成字符串再画
+			String s = randomChar() + "";
+			//添加到StringBuilder里面
+			sb.append(s);
+			//定义字符的x坐标
+			float x = i * 1.0F * weight / 4;
+			//设置字体,随机
+			g.setFont(randomFont());
+			//设置颜色,随机
+			g.setColor(randomColor());
+			g.drawString(s, x, height - 5);
+		}
+		this.text = sb.toString();
+		drawLine(image);
+		return image;
+	}
+
+	/**
+	 * 获取验证码文本的方法
+	 *
+	 * @return
+	 */
+	public String getText() {
+		return text;
+	}
+}

+ 57 - 0
blade-auth/src/main/java/org/springblade/auth/verification/verificationController.java

@@ -0,0 +1,57 @@
+package org.springblade.auth.verification;
+
+import com.alibaba.druid.util.StringUtils;
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import org.springblade.auth.utils.ImgVerifyCode;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+
+@RestController
+@RequestMapping("/verification")
+@AllArgsConstructor
+@Api(value = "验证码", tags = "验证码相关接口")
+public class verificationController {
+
+	private final RedisTemplate<String, Object> redisTemplate;
+
+
+	@GetMapping("/getVerificationCodeAction")
+	@ResponseBody
+	public String getVerifiCode(HttpServletResponse response) throws IOException {
+
+		//获取图形验证码
+		ImgVerifyCode imageVerificationCode = new ImgVerifyCode();
+		BufferedImage image = imageVerificationCode.getImage();
+
+		String validationCode = imageVerificationCode.getText();
+
+		//将验证码图片响应给客户端
+		ImgVerifyCode.output(image, response.getOutputStream());
+		return validationCode;
+	}
+
+
+	/**
+	 * 校验验证码接口
+	 *
+	 * @return
+	 * */
+
+	@GetMapping("/checkVerify")
+	@ResponseBody
+	public boolean checkVerify(HttpServletRequest request, HttpServletResponse response, @RequestParam String validationCode) {
+		String rightValidationCode = (String) request.getSession().getAttribute("validationCode");
+		if (StringUtils.isEmpty(rightValidationCode) || !rightValidationCode.toLowerCase().equals(validationCode.toLowerCase())) {
+			return false;
+		}
+		return true;
+	}
+
+}

+ 44 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/dto/CorpsDescDto.java

@@ -23,6 +23,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springblade.client.entity.CorpsAddr;
+import org.springblade.client.entity.CorpsFiles;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -151,5 +153,47 @@ public class CorpsDescDto implements Serializable {
 	@TableField(exist = false)
 	private Long ids;
 
+	/**
+	 * 客户地址
+	 */
+	@ApiModelProperty(value = "客户地址")
+	@TableField(exist = false)
+	private List<CorpsAddr> corpsAddrList;
+
+	/**
+	 * 客户文件
+	 */
+	@ApiModelProperty(value = "客户文件")
+	@TableField(exist = false)
+	private List<CorpsFiles> corpsFiles;
+
+	/**
+	 * 备注
+	 */
+	@ApiModelProperty(value = "备注")
+	private String remarks;
+
+	/**
+	 * 邮箱
+	 */
+	@ApiModelProperty(value = "邮箱")
+	private String mailbox;
+
+	/**
+	 * 传真
+	 */
+	@ApiModelProperty(value = "传真")
+	private String Fax;
+	/**
+	 * 期初欠款
+	 */
+	@ApiModelProperty(value = "期初欠款")
+	private BigDecimal arrears;
+	/**
+	 * 备用电话
+	 */
+	@ApiModelProperty(value = "备用电话")
+	private String telephone;
+
 
 }

+ 6 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/CorpsAddr.java

@@ -115,5 +115,11 @@ public class CorpsAddr implements Serializable {
 		@ApiModelProperty(value = "租户id")
 	    private String tenantId;
 
+	/**
+	 * 租户id
+	 */
+	@ApiModelProperty(value = "租户id")
+	private String type;
+
 
 }

+ 22 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/CorpsDesc.java

@@ -389,5 +389,27 @@ public class CorpsDesc implements Serializable {
 	 */
 	@ApiModelProperty(value = "优势航线")
 	private String line;
+	/**
+	 * 邮箱
+	 */
+	@ApiModelProperty(value = "邮箱")
+	private String mailbox;
+
+	/**
+	 * 传真
+	 */
+	@ApiModelProperty(value = "传真")
+	private String Fax;
+	/**
+	 * 期初欠款
+	 */
+	@ApiModelProperty(value = "期初欠款")
+	private BigDecimal arrears;
+	/**
+	 * 备用电话
+	 */
+	@ApiModelProperty(value = "备用电话")
+	private String telephone;
+
 
 }

+ 11 - 15
blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java

@@ -17,21 +17,16 @@
 package org.springblade.system.user.feign;
 
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.core.launch.constant.AppConstant;
-import org.springblade.core.mp.support.Query;
-import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.entity.UserInfo;
 import org.springblade.system.user.entity.UserOauth;
-import org.springblade.system.user.vo.UserVO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
-import springfox.documentation.annotations.ApiIgnore;
 
 import java.util.List;
 import java.util.Map;
@@ -56,15 +51,15 @@ public interface IUserClient {
 	String UPDATE_USER = API_PREFIX + "/update-user";
 	String REMOVE_USER = API_PREFIX + "/remove-user";
 	String GAIN_USER = API_PREFIX + "/gainUser";
-	String USER_INFO_BY_NAME=API_PREFIX+"/user-info-by-name";
-	String LIST_USER_BY_ROLE_ID=API_PREFIX+"/listUserByRoleId";
-	String GET_USER_PAGE=API_PREFIX+"/getUserPage";
-	String USER_BY_IDS = API_PREFIX+ "/selectUserIds";
-	String USER_ALL = API_PREFIX+ "/selectUserAll";
-	String LOGIN_BY_ACCOUNT = API_PREFIX+ "/loginByAccount";
+	String USER_INFO_BY_NAME = API_PREFIX + "/user-info-by-name";
+	String LIST_USER_BY_ROLE_ID = API_PREFIX + "/listUserByRoleId";
+	String GET_USER_PAGE = API_PREFIX + "/getUserPage";
+	String USER_BY_IDS = API_PREFIX + "/selectUserIds";
+	String USER_ALL = API_PREFIX + "/selectUserAll";
+	String LOGIN_BY_ACCOUNT = API_PREFIX + "/loginByAccount";
 
 	@GetMapping(LIST_USER_BY_ROLE_ID)
-	R<List<User>> listUserByRoleId(@RequestParam("roleId")Long roleId);
+	R<List<User>> listUserByRoleId(@RequestParam("roleId") Long roleId);
 
 	/**
 	 * 获取用户信息
@@ -73,7 +68,7 @@ public interface IUserClient {
 	 * @return
 	 */
 	@GetMapping(USER_INFO_BY_NAME)
-	List<User> userInfoByName(@RequestParam("userName") String userName,@RequestParam("tenantId") String tenantId);
+	List<User> userInfoByName(@RequestParam("userName") String userName, @RequestParam("tenantId") String tenantId);
 
 	/**
 	 * 根据修改人或创建人获取用户信息
@@ -160,11 +155,12 @@ public interface IUserClient {
 	 */
 	@PostMapping(REMOVE_USER)
 	R<Boolean> removeUser(@RequestParam("tenantIds") String tenantIds);
+
 	/**
 	 * 根据租户id获取用户信息
 	 */
 	@GetMapping(GAIN_USER)
-	R<List<Map<String,Object>>> gainUser();
+	R<List<Map<String, Object>>> gainUser();
 
 	/**
 	 * 获取用户
@@ -193,6 +189,6 @@ public interface IUserClient {
 	 * @return
 	 */
 	@GetMapping(LOGIN_BY_ACCOUNT)
-	User loginByAccount(@RequestParam("account") String account);
+	User loginByAccount(@RequestParam(value = "account", required = false) String account, @RequestParam(value = "phone", required = false) String phone);
 
 }

+ 14 - 0
blade-service/blade-client/src/main/java/org/springblade/client/common/controller/CommonFileController.java

@@ -150,5 +150,19 @@ public class CommonFileController extends BladeController {
 		return R.status(commonFileService.removeFile(Func.toLongList(ids)));
 	}
 
+	/**
+	 * 列表 公共文件表(app轮播图)
+	 */
+	@GetMapping("/carouselChartList")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入commonFile")
+	public R<List<CommonFile>> carouselChartList() {
+		return R.data(commonFileService.list(new LambdaQueryWrapper<CommonFile>()
+			.eq(CommonFile::getType, 99)
+			.eq(CommonFile::getTenantId, AuthUtil.getTenantId())
+			.eq(CommonFile::getIsDeleted, 0)
+		));
+	}
+
 
 }

+ 12 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/controller/CorpsDescPartsController.java

@@ -20,6 +20,7 @@ import org.springblade.purchase.sales.entity.Order;
 import org.springblade.purchase.sales.feign.IOrderDescClient;
 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.math.BigDecimal;
@@ -176,4 +177,15 @@ public class CorpsDescPartsController extends BladeController {
 		return R.data(list);
 	}
 
+	/**
+	 * 客户详情
+	 */
+	@GetMapping("/getDetails")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "", notes = "")
+	public R getDetails(@RequestParam("id") Long id) {
+		CorpsDescDto corpsDescDto = corpsDescService.getDetailsById(id);
+		return R.data(corpsDescDto);
+	}
+
 }

+ 1 - 1
blade-service/blade-client/src/main/java/org/springblade/client/corps/mapper/CorpsDescMapper.java

@@ -105,5 +105,5 @@ public interface CorpsDescMapper extends BaseMapper<CorpsDesc> {
 	 * @param corpsDescDto
 	 * @return
 	 */
-	List<CorpsDescDto> selectPartsCorpsStatistics(CorpsDescDto corpsDescDto);
+	List<CorpsDescDto> selectPartsCorpsStatistics(@Param("CorpsDesc")CorpsDescDto corpsDescDto);
 }

+ 7 - 0
blade-service/blade-client/src/main/java/org/springblade/client/corps/service/ICorpsDescService.java

@@ -196,4 +196,11 @@ public interface ICorpsDescService extends IService<CorpsDesc> {
 	 * @return
 	 */
     List<CorpsDescDto> selectPartsCorpsStatistics(CorpsDescDto corpsDescDto);
+
+	/**
+	 *
+	 * @param id
+	 * @return
+	 */
+	CorpsDescDto getDetailsById(Long id);
 }

+ 96 - 29
blade-service/blade-client/src/main/java/org/springblade/client/corps/service/impl/CorpsDescServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.AllArgsConstructor;
@@ -22,12 +23,16 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.finance.feign.IFinanceClient;
+import org.springblade.purchase.sales.entity.Order;
+import org.springblade.purchase.sales.feign.IOrderDescClient;
 import org.springblade.system.feign.ISysClient;
 import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -59,13 +64,17 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 
 	private final ISysClient sysClient;
 
+	private final IOrderDescClient orderDescClient;
+
+	private final IFinanceClient financeClient;
+
 	static final int GB_SP_DIFF = 160;
 	// 存放国标一级汉字不同读音的起始区位码
-	static final int[] secPosValueList = { 1601, 1637, 1833, 2078, 2274, 2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635,
-		3722, 3730, 3858, 4027, 4086, 4390, 4558, 4684, 4925, 5249, 5600 };
+	static final int[] secPosValueList = {1601, 1637, 1833, 2078, 2274, 2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635,
+		3722, 3730, 3858, 4027, 4086, 4390, 4558, 4684, 4925, 5249, 5600};
 	// 存放国标一级汉字不同读音的起始区位码对应读音
-	static final char[] firstLetter = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
-		'R', 'S', 'T', 'W', 'X', 'Y', 'Z' };
+	static final char[] firstLetter = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
+		'R', 'S', 'T', 'W', 'X', 'Y', 'Z'};
 
 	@Override
 	public IPage<CorpsDescVO> selectCorpsDescPage(IPage<CorpsDescVO> page, CorpsDescVO corpsDesc) {
@@ -76,15 +85,15 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 			corpsTypeService.selectChildById(corpsTypeId, corpsTypeIdList);
 			corpsTypeIdList.add(corpsTypeId);
 			corpsDesc.setTypeList(corpsTypeIdList);
-		}else if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeName())){
+		} else if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeName())) {
 			LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-			lambdaQueryWrapper.eq(CorpsType::getCname,corpsDesc.getCorpsTypeName());
-			lambdaQueryWrapper.eq(CorpsType::getIsDeleted,0);
-			lambdaQueryWrapper.eq(CorpsType::getTenantId,SecureUtil.getTenantId());
+			lambdaQueryWrapper.eq(CorpsType::getCname, corpsDesc.getCorpsTypeName());
+			lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
+			lambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
 			List<CorpsType> corpsTypeList = corpsTypeMapper.selectList(lambdaQueryWrapper);
-			if (CollectionUtils.isNotEmpty(corpsTypeList)){
+			if (CollectionUtils.isNotEmpty(corpsTypeList)) {
 				List<Long> corpsTypeIdList = new ArrayList<>();
-				corpsTypeList.stream().forEach(item ->{
+				corpsTypeList.stream().forEach(item -> {
 					corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
 					corpsTypeIdList.add(item.getId());
 				});
@@ -96,7 +105,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 	}
 
 	@Override
-	public List<CorpsDesc> selectShippingCompany(CorpsDesc corpsDesc){
+	public List<CorpsDesc> selectShippingCompany(CorpsDesc corpsDesc) {
 		return baseMapper.selectShippingCompany(corpsDesc);
 	}
 
@@ -105,7 +114,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 	public R submit(CorpsDesc corpsDesc) {
 		Long userId = SecureUtil.getUserId();
 		Date date = new Date();
-		if (null == corpsDesc.getInitials() || "" == corpsDesc.getInitials()){//首字母为空
+		if (null == corpsDesc.getInitials() || "" == corpsDesc.getInitials()) {//首字母为空
 			//获得名称首字母
 			String initials = getSpells(corpsDesc.getCname());
 			corpsDesc.setInitials(initials.substring(0, 1));
@@ -593,7 +602,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 
 	@Override
 	public CorpsDesc selectCode(String code, String tenantId, String corpType) {
-		return baseMapper.getCorpMessage(code,tenantId,corpType);
+		return baseMapper.getCorpMessage(code, tenantId, corpType);
 	}
 
 	@Override
@@ -608,6 +617,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 
 	/**
 	 * 添加客户信息
+	 *
 	 * @param corpsDesc
 	 * @return
 	 */
@@ -623,8 +633,8 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 	 * @return
 	 */
 	@Override
-	public List<CorpsDesc> selectByCorpIds(String ids){
-		if (ids == null || ids.equals("")){
+	public List<CorpsDesc> selectByCorpIds(String ids) {
+		if (ids == null || ids.equals("")) {
 			return new ArrayList<>();
 		}
 		List<Long> collect = Arrays.stream(ids.split(","))
@@ -642,15 +652,15 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 			corpsTypeService.selectChildById(corpsTypeId, corpsTypeIdList);
 			corpsTypeIdList.add(corpsTypeId);
 			corpsDescDto.setTypeList(corpsTypeIdList);
-		}else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())){
+		} else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())) {
 			LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-			lambdaQueryWrapper.eq(CorpsType::getCname,corpsDescDto.getCorpsTypeName());
-			lambdaQueryWrapper.eq(CorpsType::getIsDeleted,0);
-			lambdaQueryWrapper.eq(CorpsType::getTenantId,SecureUtil.getTenantId());
+			lambdaQueryWrapper.eq(CorpsType::getCname, corpsDescDto.getCorpsTypeName());
+			lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
+			lambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
 			List<CorpsType> corpsTypeList = corpsTypeMapper.selectList(lambdaQueryWrapper);
-			if (CollectionUtils.isNotEmpty(corpsTypeList)){
+			if (CollectionUtils.isNotEmpty(corpsTypeList)) {
 				List<Long> corpsTypeIdList = new ArrayList<>();
-				corpsTypeList.stream().forEach(item ->{
+				corpsTypeList.stream().forEach(item -> {
 					corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
 					corpsTypeIdList.add(item.getId());
 				});
@@ -664,6 +674,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 
 	/**
 	 * 列表统计
+	 *
 	 * @param corpsDescDto
 	 * @return
 	 */
@@ -676,15 +687,15 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 			corpsTypeService.selectChildById(corpsTypeId, corpsTypeIdList);
 			corpsTypeIdList.add(corpsTypeId);
 			corpsDescDto.setTypeList(corpsTypeIdList);
-		}else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())){
+		} else if (StringUtils.isNotBlank(corpsDescDto.getCorpsTypeName())) {
 			LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-			lambdaQueryWrapper.eq(CorpsType::getCname,corpsDescDto.getCorpsTypeName());
-			lambdaQueryWrapper.eq(CorpsType::getIsDeleted,0);
-			lambdaQueryWrapper.eq(CorpsType::getTenantId,SecureUtil.getTenantId());
+			lambdaQueryWrapper.eq(CorpsType::getCname, corpsDescDto.getCorpsTypeName());
+			lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
+			lambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
 			List<CorpsType> corpsTypeList = corpsTypeMapper.selectList(lambdaQueryWrapper);
-			if (CollectionUtils.isNotEmpty(corpsTypeList)){
+			if (CollectionUtils.isNotEmpty(corpsTypeList)) {
 				List<Long> corpsTypeIdList = new ArrayList<>();
-				corpsTypeList.stream().forEach(item ->{
+				corpsTypeList.stream().forEach(item -> {
 					corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
 					corpsTypeIdList.add(item.getId());
 				});
@@ -696,6 +707,61 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 		return baseMapper.selectPartsCorpsStatistics(corpsDescDto);
 	}
 
+
+	@Override
+	public CorpsDescDto getDetailsById(Long id) {
+		CorpsDescDto corpsDescDto = new CorpsDescDto();
+		CorpsDesc corpsDesc = baseMapper.selectById(id);
+		//应收账款
+		BigDecimal debitAmount = new BigDecimal("0.00");
+		//已收账款
+		BigDecimal settlmentAmount = new BigDecimal("0.00");
+		//未收账款
+		BigDecimal balanceAmount = new BigDecimal("0.00");
+		// 预(收)付款
+		BigDecimal advancePayment = new BigDecimal("0.00");
+		if (ObjectUtils.isNotNull(corpsDesc)) {
+			//客户信息
+			corpsDescDto = BeanUtil.copy(corpsDesc, CorpsDescDto.class);
+			//获取订单记录
+			Order order = new Order();
+			order.setCorpId(corpsDesc.getId());
+			order.setBillType("XS");
+			order.setTradeType("JXS");
+			List<Order> orderList = orderDescClient.getByBillNo(order);
+			if (ObjectUtils.isNotNull(orderList)) {
+				//未收账款
+				balanceAmount = balanceAmount.add(orderList.stream().map(Order::getBalanceAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				//应收账款
+				debitAmount = debitAmount.add(orderList.stream().map(Order::getDebitAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				//已收账款
+				settlmentAmount = settlmentAmount.add(orderList.stream().map(Order::getSettlmentAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+				//预(收)付款
+				advancePayment = advancePayment.add(orderList.stream().map(Order::getAdvancePayment).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
+			}
+
+			//未收账款
+			corpsDescDto.setBalanceAmount(balanceAmount);
+			//应收账款
+			corpsDescDto.setDebitAmount(debitAmount);
+			//已收账款
+			corpsDescDto.setSettlmentAmount(settlmentAmount);
+			//预(收)付款
+			corpsDescDto.setAdvancePayment(advancePayment);
+
+			//获取客户文件
+			corpsDescDto.setCorpsFiles(corpsFilesService.list(new QueryWrapper<CorpsFiles>().eq("pid", corpsDesc.getId()).eq("is_deleted", 0).eq("status", 0)));
+			//获取客户地址
+			corpsDescDto.setCorpsAddrList(corpsAddrService.list(new QueryWrapper<CorpsAddr>().eq("pid", corpsDesc.getId()).eq("is_deleted", 0).eq("status", 0)));
+
+			//获取客户类别
+			List<String> longs = corpsTypeDescMapper.selectTypeId(corpsDesc.getId());
+			corpsDescDto.setCorpsTypeId(String.join(",", longs));
+
+		}
+		return corpsDescDto;
+	}
+
 	/**
 	 * 保护客户联系人信息
 	 *
@@ -874,6 +940,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 
 	/**
 	 * 提取汉字字符串的首字母
+	 *
 	 * @param characters 汉字字符串
 	 * @return
 	 */
@@ -895,6 +962,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 
 	/**
 	 * 获取一个汉字的首字母
+	 *
 	 * @param ch 汉字
 	 * @return
 	 */
@@ -903,7 +971,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 		byte[] uniCode = null;
 		try {
 			uniCode = String.valueOf(ch).getBytes("GBK");
-		}  catch (Exception e) {
+		} catch (Exception e) {
 			e.printStackTrace();
 			return null;
 		}
@@ -937,5 +1005,4 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, CorpsDesc
 	}
 
 
-
 }

+ 3 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.java

@@ -228,4 +228,7 @@ public interface OrderMapper extends BaseMapper<Order> {
 	List<OrderDetailedExcel> orderDetailedExport(@Param("order") OrderReconciliationVo order);
 
 	int updateStockGoods(StockGoods stockGoods);
+
+	BigDecimal arrears(@Param("tenantId") String tenantId,
+					   @Param("tradeType") String tradeType);
 }

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

@@ -1435,6 +1435,19 @@ ORDER BY
             </if>
         </where>
     </select>
+    <select id="arrears" resultType="java.math.BigDecimal">
+        SELECT
+        SUM(BO.balance_amount) as ProcurementExpenditure
+        FROM business_order BO
+        <where>
+            BO.is_deleted = 0
+            AND BO.bill_type = 'CG'
+            AND BO.tenant_id = #{tenantId}
+            <if test="tradeType != null and tradeType != ''">
+                AND BO.trade_type = #{tradeType}
+            </if>
+        </where>
+    </select>
     <update id="updateStockGoods" parameterType="org.springblade.stock.entity.StockGoods">
         UPDATE business_stock_goods SET surplus_route_quantity = #{surplusRouteQuantity},locking_quantity = #{lockingQuantity} WHERE tenant_id = #{tenantId} AND id = #{id} AND is_deleted = 0
     </update>

+ 103 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/partsapp/AppPartsController.java

@@ -0,0 +1,103 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.purchase.sales.partsapp;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import com.trade.purchase.order.enums.OrderTypeEnum;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.client.entity.CorpsDesc;
+import org.springblade.client.entity.FeesDesc;
+import org.springblade.client.feign.ICorpsDescClient;
+import org.springblade.client.feign.IFeesDescClient;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.excel.util.ExcelUtil;
+import org.springblade.core.mp.support.Condition;
+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.feign.IFinanceClient;
+import org.springblade.finance.vojo.Acc;
+import org.springblade.purchase.sales.entity.Order;
+import org.springblade.purchase.sales.entity.OrderFees;
+import org.springblade.purchase.sales.entity.OrderItems;
+import org.springblade.purchase.sales.excel.SaleOrderExcel;
+import org.springblade.purchase.sales.service.*;
+import org.springblade.purchase.sales.vo.OrderItemsVO;
+import org.springblade.purchase.sales.vo.OrderStatisticAnalysisVO;
+import org.springblade.purchase.sales.vo.OrderVO;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 国内销售或采购订单表 控制器
+ *
+ * @author BladeX
+ * @since 2021-09-26
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/appParts")
+@Api(value = "国内销售订单", tags = "国内销售订单")
+public class AppPartsController extends BladeController {
+
+	private final IOrderService orderService;
+	private final IOrderItemsService orderItemsService;
+	private final IOrderFeesService orderFeesService;
+	private final IOrderFilesService orderFilesService;
+	private final IOrderFreightService orderFreightService;
+	private final IOrderModifyService orderModifyService;
+	private final IOrderPartsService orderPartsService;
+	private final ICorpsDescClient corpsDescClient;//获取客户信息
+	private final IUserClient userClient;//获取用户信息
+	private final IFeesDescClient feesDescClient;
+	private final IFinanceClient iFinanceClient;
+	private final IDeliveryClient deliveryClient;
+
+	/**
+	 * 获得app首页营业收入和采购支出(配件系统)
+	 * @param tenantId
+	 * @return
+	 */
+	@GetMapping("/revenueExpenditure")
+	@ApiOperation(value = "营业收入和采购支出", notes = "传入order")
+	public R revenueExpenditure(@RequestParam("tenantId") String tenantId){
+		return R.data(orderService.revenueExpenditure(tenantId));
+	}
+
+}

+ 8 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/IOrderService.java

@@ -159,6 +159,14 @@ public interface IOrderService extends IService<Order> {
 	 */
 	OrderIncomeVo orderIncome(OrderVO Order);
 
+
+	/**
+	 * 获得app首页营业收入和采购支出(配件系统)
+	 * @param tenantId
+	 * @return
+	 */
+	OrderIncomeVo revenueExpenditure(String tenantId);
+
 	/**
 	 * 平台订单审核通过
 	 * @param id

+ 44 - 5
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java

@@ -344,9 +344,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 				BigDecimal reduce = list.stream().reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getPurchaseAmount().multiply(y.getOrderQuantity())), BigDecimal::add);
 				// 金额求和
 				BigDecimal amount = BigDecimal.ZERO;
-				if (AuthUtil.getTenantId().equals("577435")){
+				if (AuthUtil.getTenantId().equals("577435")) {
 					amount = list.stream().map(OrderItems::getOutFactoryPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-				}else {
+				} else {
 					amount = list.stream().map(OrderItems::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
 				}
 				//毛利额 = 销售金额-采购金额-预计海运费-本次使用返利+应收费用(除包装费)
@@ -1657,7 +1657,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 							feesMap.put("unit", "40HC");
 							feesMap.put("price", orderCostItem.getFortyHc());
 						}
-					} else if (orderCostItem.getType() == 3){//杂费
+					} else if (orderCostItem.getType() == 3) {//杂费
 						//杂费 = 票费用/汇率  || 票费用
 						amount = amount.add(orderCostItem.getTicket());
 						feesMap.put("unit", "JOB");
@@ -1709,7 +1709,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 							feesMap.put("unit", "40HC");
 							feesMap.put("price", orderCostItem.getFortyHc());
 						}
-					} else if (orderCostItem.getType() == 3){//杂费
+					} else if (orderCostItem.getType() == 3) {//杂费
 						//杂费 = 票费用/汇率  || 票费用
 						amount = amount.add(orderCostItem.getTicket());
 						feesMap.put("unit", "JOB");
@@ -1721,7 +1721,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 			}
 		}
 		//分摊费用额 = 总费用/总货值
-		if(!amount.equals(new BigDecimal(0))){
+		if (!amount.equals(new BigDecimal(0))) {
 			if (order.getDomesticAbroad().equals("1") && order.getCurrency().equals("CNY")) {
 				amount = amount;
 			} else if (order.getDomesticAbroad().equals("1") && order.getCurrency().equals("USD")) {
@@ -1833,6 +1833,45 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 		return incomeVo;
 	}
 
+	/**
+	 * 获得app首页营业收入和采购支出(配件系统)
+	 *
+	 * @param tenantId
+	 * @return
+	 */
+	@Override
+	public OrderIncomeVo revenueExpenditure(String tenantId) {
+
+		String tradeType = "";
+
+		OrderIncomeVo incomeVo = new OrderIncomeVo();
+		if (StringUtils.isBlank(tenantId)) {
+			tenantId = SecureUtil.getTenantId();
+		}
+
+		//获得当前租户信息
+		Tenant tenant = iTenantClient.tenantMessage(tenantId);
+		//判断贸易类型
+		if (ObjectUtil.isNotEmpty(tenant)) {
+			//根据公司类型判断贸易类型
+			if (2 == tenant.getBillType()) {
+				tradeType = "GN";
+			} else if (3 == tenant.getBillType()) {
+				tradeType = "JK";
+			} else if (4 == tenant.getBillType()) {
+				tradeType = "CK";
+			}
+			//获得租户名称
+			incomeVo.setTenantName(tenant.getTenantName());
+		}
+
+		//获得营业收入
+		incomeVo.setBusinessIncome(baseMapper.orderIncome(tenantId, tradeType, null, null));
+		//获得欠款金额
+		incomeVo.setProcurementExpenditure(baseMapper.arrears(tenantId, tradeType));
+		return incomeVo;
+	}
+
 	@Override
 	public void approve(Long id) {
 		LambdaQueryWrapper<Order> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();

+ 17 - 24
blade-service/blade-user/src/main/java/org/springblade/system/user/feign/UserClient.java

@@ -17,26 +17,19 @@
 package org.springblade.system.user.feign;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
-import org.springblade.core.mp.support.Condition;
-import org.springblade.core.mp.support.Query;
-import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tenant.annotation.NonDS;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.utils.Func;
-import org.springblade.core.tool.utils.StringPool;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.entity.UserInfo;
 import org.springblade.system.user.entity.UserOauth;
 import org.springblade.system.user.enums.UserEnum;
 import org.springblade.system.user.service.IUserService;
-import org.springblade.system.user.vo.UserVO;
-import org.springblade.system.user.wrapper.UserWrapper;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -60,27 +53,26 @@ public class UserClient implements IUserClient {
 	@Override
 	@GetMapping(LIST_USER_BY_ROLE_ID)
 	public R<List<User>> listUserByRoleId(Long roleId) {
-		LambdaQueryWrapper<User> userLambdaQueryWrapper=new LambdaQueryWrapper<>();
+		LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
 		userLambdaQueryWrapper
-			.eq(User::getIsDeleted,0)
-			.eq(User::getRoleId,roleId)
+			.eq(User::getIsDeleted, 0)
+			.eq(User::getRoleId, roleId)
 			.eq(User::getTenantId, AuthUtil.getTenantId());
 		return R.data(service.list(userLambdaQueryWrapper));
 	}
 
 	@Override
 	@GetMapping(USER_BY_IDS)
-	public List<User> selectUserIds(String userIds){
+	public List<User> selectUserIds(String userIds) {
 		return service.selectUserIds(userIds);
 	}
 
 	@Override
 	@GetMapping(USER_INFO_BY_NAME)
-	public List<User> userInfoByName(String userName,String tenantId)
-	{
-		LambdaQueryWrapper<User> userLambdaQueryWrapper=new LambdaQueryWrapper<>();
-		userLambdaQueryWrapper.eq(User::getTenantId,tenantId);
-		userLambdaQueryWrapper.like(User::getRealName,userName);
+	public List<User> userInfoByName(String userName, String tenantId) {
+		LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
+		userLambdaQueryWrapper.eq(User::getTenantId, tenantId);
+		userLambdaQueryWrapper.like(User::getRealName, userName);
 		return service.list(userLambdaQueryWrapper);
 	}
 
@@ -141,9 +133,9 @@ public class UserClient implements IUserClient {
 	@Override
 	@GetMapping(USER_ALL)
 	public List<User> selectUserAll() {
-		LambdaQueryWrapper<User> userLambdaQueryWrapper=new LambdaQueryWrapper<>();
-		userLambdaQueryWrapper.eq(User::getTenantId,AuthUtil.getTenantId());
-		userLambdaQueryWrapper.eq(User::getIsDeleted,0);
+		LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
+		userLambdaQueryWrapper.eq(User::getTenantId, AuthUtil.getTenantId());
+		userLambdaQueryWrapper.eq(User::getIsDeleted, 0);
 		return service.list(userLambdaQueryWrapper);
 	}
 
@@ -155,10 +147,11 @@ public class UserClient implements IUserClient {
 	 * @return
 	 */
 	@Override
-	public User loginByAccount(String account) {
-		LambdaQueryWrapper<User> userLambdaQueryWrapper=new LambdaQueryWrapper<>();
-		userLambdaQueryWrapper.eq(User::getAccount,account);
-		userLambdaQueryWrapper.eq(User::getIsDeleted,0);
+	public User loginByAccount(String account, String phone) {
+		LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
+		userLambdaQueryWrapper.eq(ObjectUtils.isNotNull(account),User::getAccount, account);
+		userLambdaQueryWrapper.eq(ObjectUtils.isNotNull(phone),User::getPhone, phone);
+		userLambdaQueryWrapper.eq(User::getIsDeleted, 0);
 		return service.getOne(userLambdaQueryWrapper);
 	}
 

+ 8 - 3
blade-service/trade-purchase/src/main/java/com/trade/purchase/order/service/impl/OrderItemsServiceImpl.java

@@ -15,6 +15,7 @@ import lombok.AllArgsConstructor;
 import org.springblade.client.entity.CorpsDesc;
 import org.springblade.client.entity.GoodsDesc;
 import org.springblade.client.entity.StorageDesc;
+import org.springblade.client.feign.IGoodsDescClient;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
@@ -40,6 +41,8 @@ public class OrderItemsServiceImpl extends ServiceImpl<OrderItemsMapper, OrderIt
 
 	private final RedisTemplate<String, Object> redisTemplate;
 
+	private IGoodsDescClient goodsDescClient;//获取商品信息
+
 	@Override
 	public IPage<OrderItemsVO> selectOrderItemsPage(IPage<OrderItemsVO> page, OrderItemsVO orderItems) {
 		return page.setRecords(baseMapper.selectOrderItemsPage(page, orderItems));
@@ -99,12 +102,14 @@ public class OrderItemsServiceImpl extends ServiceImpl<OrderItemsMapper, OrderIt
 
 		List<OrderItems> orderItemsList = baseMapper.receiptItemPrint(ids);
 
-		//库区
-		List<GoodsDesc> goodsDescList = castToList(redisTemplate.opsForValue().get("goods"), GoodsDesc.class);
+		//商品
+		List<GoodsDesc> goodsList = new ArrayList<>();
+//		goodsList = castToList(redisTemplate.opsForValue().get("goods"), GoodsDesc.class);
+		goodsList = goodsDescClient.selectGoodsDescAll();
 		for (OrderItems orderItems : orderItemsList) {
 			if (ObjectUtils.isNotNull(orderItems.getItemId())) {
 				//货权人
-				GoodsDesc goodsDesc = goodsDescList.stream().filter(goods -> goods.getId().equals(orderItems.getItemId())).findFirst().orElse(null);
+				GoodsDesc goodsDesc = goodsList.stream().filter(goods -> goods.getId().equals(orderItems.getItemId())).findFirst().orElse(null);
 				if (ObjectUtils.isNotNull(goodsDesc)) {
 					orderItems.setCname(goodsDesc.getCname());
 				}

+ 6 - 6
blade-service/trade-purchase/src/main/java/com/trade/purchase/order/service/impl/OrderServiceImpl.java

@@ -1,6 +1,5 @@
 package com.trade.purchase.order.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -210,7 +209,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	public R<OrderVO> getOrderMessage(String id) {
 		//客户
 		List<CorpsDesc> corpsDescList = castToList(redisTemplate.opsForValue().get("corps"), CorpsDesc.class);
-		if (ObjectUtils.isNull(corpsDescList)) {
+		if (corpsDescList.size() == 0) {
 			CorpsDesc corpsDesc = new CorpsDesc();
 			corpsDesc.setTenantId(AuthUtil.getTenantId());
 			corpsDescList = corpsDescClient.getCorp(corpsDesc);
@@ -993,11 +992,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	public List<CMYWarehousingExcel> warehousing(List<CMYWarehousingExcel> excelList) {
 		//商品
 		List<GoodsDesc> goodsList = new ArrayList<>();
-		 goodsList = castToList(redisTemplate.opsForValue().get("goods"), GoodsDesc.class);
-		if (ObjectUtils.isNull(goodsList)) {
-			goodsList = goodsDescClient.selectGoodsDescAll();
+		goodsList = castToList(redisTemplate.opsForValue().get("goods"), GoodsDesc.class);
+		System.out.println("商品数据:" + goodsList);
+		if (goodsList.size() == 0) {
 			redisClient.basicData("all");
 		}
+		goodsList = goodsDescClient.selectGoodsDescAll();
 		//库区
 		List<StorageDesc> storageDescList = castToList(redisTemplate.opsForValue().get("storageDesc"), StorageDesc.class);
 
@@ -2152,7 +2152,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	public IPage<Order> selectOrderList(Order order, Query query) {
 		//客户
 		List<CorpsDesc> corpsDescList = castToList(redisTemplate.opsForValue().get("corps"), CorpsDesc.class);
-		if (ObjectUtils.isNull(corpsDescList)) {
+		if (corpsDescList.size() == 0) {
 			CorpsDesc corpsDesc = new CorpsDesc();
 			corpsDesc.setTenantId(AuthUtil.getTenantId());
 			corpsDescList = corpsDescClient.getCorp(corpsDesc);