|
@@ -15,11 +15,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.szwl.common.aop.LogAnnotation;
|
|
|
import com.szwl.constant.ConfigConsts;
|
|
|
import com.szwl.constant.ResponseCodesEnum;
|
|
|
+import com.szwl.exception.BizException;
|
|
|
import com.szwl.feign.SzwlFeign;
|
|
|
+import com.szwl.manager.TokenManager;
|
|
|
import com.szwl.model.bean.*;
|
|
|
import com.szwl.model.bo.JsonMessage;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
+import com.szwl.model.bo.UserDetailBO;
|
|
|
import com.szwl.model.dto.OrderDto;
|
|
|
import com.szwl.model.entity.*;
|
|
|
import com.szwl.model.excel.CoinOrderTarget;
|
|
@@ -82,6 +85,8 @@ public class TOrderController {
|
|
|
SzwlFeign szwlFeign;
|
|
|
@Autowired
|
|
|
TOrderDetailsService orderDetailsService;
|
|
|
+ @Autowired
|
|
|
+ TokenManager tokenManager;
|
|
|
|
|
|
@ApiOperation(value = "订单列表")
|
|
|
@GetMapping("/pageOrder")
|
|
@@ -90,8 +95,14 @@ public class TOrderController {
|
|
|
String payType, String productNo, String clientId,
|
|
|
String trxNo, String dateType, String startDate,
|
|
|
String companyType, String machineType, String endDate, long current, long size) {
|
|
|
+
|
|
|
+ UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
|
|
|
+ .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
|
|
|
+ String authId = userDetailBO.getId().toString();
|
|
|
+ String username = userDetailBO.getUsername();
|
|
|
+
|
|
|
//判断当前账号状态
|
|
|
- TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(adminId));
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(authId));
|
|
|
if (StringUtils.isEmpty(type)) {
|
|
|
if (StringUtils.isNotEmpty(admin.getIfForeign())) {
|
|
|
// 0 国内,1 海外
|
|
@@ -109,9 +120,9 @@ public class TOrderController {
|
|
|
//0,线上 -》 国内
|
|
|
if (type.equals("0")) {
|
|
|
LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
- if (!userName.equals("admin")) {
|
|
|
- if (StringUtils.isNotEmpty(userName)) {
|
|
|
- ResponseModel<TAdmin> adminByUsername = szwlFeign.getAdminByUsername(userName);
|
|
|
+ if (!username.equals("admin")) {
|
|
|
+ if (StringUtils.isNotEmpty(username)) {
|
|
|
+ ResponseModel<TAdmin> adminByUsername = szwlFeign.getAdminByUsername(username);
|
|
|
TAdmin data = adminByUsername.getData();
|
|
|
if (data == null || data.getId() == null) {
|
|
|
return R.fail(ResponseCodesEnum.A0001, "找不到商家");
|
|
@@ -124,7 +135,7 @@ public class TOrderController {
|
|
|
//查找子账户所管理的机器
|
|
|
TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getId())));
|
|
|
if (!adminEquipment.getType().equals("0")) {
|
|
|
- List<String> list = R.getDataIfSuccess(szwlFeign.getClientIds(adminId));
|
|
|
+ List<String> list = R.getDataIfSuccess(szwlFeign.getClientIds(authId));
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
return R.fail(ResponseCodesEnum.A0001, "没有机器/no machine");
|
|
|
}
|
|
@@ -140,7 +151,7 @@ public class TOrderController {
|
|
|
if (admin.getType() > 1) {
|
|
|
if (adminType.equals("all")) {
|
|
|
//查找所有下级
|
|
|
- List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(adminId));
|
|
|
+ List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(authId));
|
|
|
query.in(TOrder::getAdminId, admidIdList);
|
|
|
}
|
|
|
}
|
|
@@ -166,7 +177,7 @@ public class TOrderController {
|
|
|
//商家 判断是否子账户
|
|
|
if (admin.getIsAdmined()) {
|
|
|
//商家自己
|
|
|
- query.eq(TOrder::getAdminId, adminId);
|
|
|
+ query.eq(TOrder::getAdminId, authId);
|
|
|
} else {
|
|
|
//商家 子账户
|
|
|
//登录账户为子账户 不查下级 只查对应机器的订单
|
|
@@ -268,7 +279,7 @@ public class TOrderController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(userName)) {
|
|
|
+ if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(username)) {
|
|
|
try {
|
|
|
query.gt(TOrder::getCreateDate, getStartTime(new Date()));
|
|
|
query.lt(TOrder::getCreateDate, getEndTime(new Date()));
|
|
@@ -293,7 +304,7 @@ public class TOrderController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(userName)) {
|
|
|
+ if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(username)) {
|
|
|
try {
|
|
|
query.gt(TOrder::getRefundDate, getStartTime(new Date()));
|
|
|
query.lt(TOrder::getRefundDate, getEndTime(new Date()));
|
|
@@ -357,13 +368,13 @@ public class TOrderController {
|
|
|
//1,海外
|
|
|
if (type.equals("1")) {
|
|
|
LambdaQueryWrapper<TCoinOrder> query = Wrappers.lambdaQuery();
|
|
|
- if (!userName.equals("admin")) {
|
|
|
+ if (!username.equals("admin")) {
|
|
|
// 如果为账户
|
|
|
if (admin.getType() > 2) {
|
|
|
- userName = null;
|
|
|
+ username = null;
|
|
|
}
|
|
|
- if (StringUtils.isNotEmpty(userName)) {
|
|
|
- ResponseModel<TAdmin> adminByUsername = szwlFeign.getAdminByUsername(userName);
|
|
|
+ if (StringUtils.isNotEmpty(username)) {
|
|
|
+ ResponseModel<TAdmin> adminByUsername = szwlFeign.getAdminByUsername(username);
|
|
|
TAdmin data = adminByUsername.getData();
|
|
|
if (data == null || data.getId() == null) {
|
|
|
return R.fail(ResponseCodesEnum.A0001, "找不到商家");
|
|
@@ -376,7 +387,7 @@ public class TOrderController {
|
|
|
//查找子账户所管理的机器
|
|
|
TAdminEquipment adminEquipment = R.getDataIfSuccess(szwlFeign.getClientIdList(String.valueOf(admin.getId())));
|
|
|
if (!adminEquipment.getType().equals("0")) {
|
|
|
- List<String> list = R.getDataIfSuccess(szwlFeign.getClientIds(adminId));
|
|
|
+ List<String> list = R.getDataIfSuccess(szwlFeign.getClientIds(authId));
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
return R.fail(ResponseCodesEnum.A0001, "没有机器/no machine");
|
|
|
}
|
|
@@ -390,7 +401,7 @@ public class TOrderController {
|
|
|
if (admin.getIsAdmined() && admin.getType() > 1) {
|
|
|
if ("all".equals(adminType)) {
|
|
|
//查找所有下级
|
|
|
- List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(adminId));
|
|
|
+ List<Long> admidIdList = R.getDataIfSuccess(szwlFeign.getAdminIdList(authId));
|
|
|
query.in(TCoinOrder::getAdminId, admidIdList);
|
|
|
}
|
|
|
} else {
|
|
@@ -415,7 +426,7 @@ public class TOrderController {
|
|
|
//商家 判断是否子账户
|
|
|
if (admin.getIsAdmined()) {
|
|
|
//商家自己
|
|
|
- query.eq(TCoinOrder::getAdminId, adminId);
|
|
|
+ query.eq(TCoinOrder::getAdminId, authId);
|
|
|
} else {
|
|
|
//商家 子账户
|
|
|
//登录账户为子账户 不查下级 只查对应机器的订单
|
|
@@ -510,7 +521,7 @@ public class TOrderController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(userName)) {
|
|
|
+ if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(username)) {
|
|
|
try {
|
|
|
query.gt(TCoinOrder::getCreateDate, getStartTime(new Date()));
|
|
|
query.lt(TCoinOrder::getCreateDate, getEndTime(new Date()));
|
|
@@ -535,7 +546,7 @@ public class TOrderController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(userName)) {
|
|
|
+ if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate) && StringUtils.isEmpty(sn) && StringUtils.isEmpty(trxNo) && StringUtils.isEmpty(clientId) && StringUtils.isEmpty(username)) {
|
|
|
try {
|
|
|
query.gt(TCoinOrder::getRefundDate, getStartTime(new Date()));
|
|
|
query.lt(TCoinOrder::getRefundDate, getEndTime(new Date()));
|
|
@@ -643,10 +654,14 @@ public class TOrderController {
|
|
|
@ApiOperation(value = "获取首页数据统计")
|
|
|
@PostMapping("/getStatistics")
|
|
|
public ResponseEntity<?> getStatistics(@RequestBody StatisticsParam param) {
|
|
|
+ UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
|
|
|
+ .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
|
|
|
+ String adminId = userDetailBO.getId().toString();
|
|
|
+
|
|
|
// 判断是否为外国
|
|
|
log.info("param:{}", param);
|
|
|
- String adminId = param.getAdminId();
|
|
|
- TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(param.getAdminId()));
|
|
|
+// String adminId = param.getAdminId();
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(adminId));
|
|
|
if (admin.getType() < 2) {
|
|
|
// 如果是超管或公司人员
|
|
|
param.setAdminId(null);
|
|
@@ -672,7 +687,7 @@ public class TOrderController {
|
|
|
param.setCompanyType("1");
|
|
|
}
|
|
|
} else {
|
|
|
- param.setIfForeign(isForeignUser(param.getAdminId()));
|
|
|
+ param.setIfForeign(isForeignUser(adminId));
|
|
|
if (admin.getType() == 2) {
|
|
|
//商家
|
|
|
if (param.getEquipmentId() != null && !param.getEquipmentId().isEmpty()) {
|
|
@@ -835,14 +850,17 @@ public class TOrderController {
|
|
|
@ApiOperation(value = "机器销售排行统计")
|
|
|
@PostMapping("/getEquipmentStatistics")
|
|
|
public ResponseEntity<?> getEquipmentStatistics(@RequestBody StatisticsParam param) {
|
|
|
+ UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
|
|
|
+ .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
|
|
|
+ String adminId = userDetailBO.getId().toString();
|
|
|
// 判断是否为外国
|
|
|
- param.setIfForeign(isForeignUser(param.getAdminId()));
|
|
|
+ param.setIfForeign(isForeignUser(adminId));
|
|
|
log.info("param:{}", param);
|
|
|
FgObjectUtil.objectNullOrEmptySel(param, "chartType$");
|
|
|
- String adminId = param.getAdminId();
|
|
|
+// String adminId = param.getAdminId();
|
|
|
ChartColumn chartColumn = new ChartColumn();
|
|
|
- if (StringUtils.isNotEmpty(param.getAdminId())) {
|
|
|
- TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(param.getAdminId())));
|
|
|
+ if (StringUtils.isNotEmpty(adminId)) {
|
|
|
+ TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(adminId)));
|
|
|
// 申泽平台管理员
|
|
|
if (admin.getId() == 2738) {
|
|
|
param.setCompanyType("0");
|