Просмотр исходного кода

修改后台管理用户列表等

VEAR 2 лет назад
Родитель
Сommit
fbf9f228a7

+ 6 - 1
src/main/java/org/springblade/common/constant/CommonConstant.java

@@ -185,10 +185,15 @@ public interface CommonConstant {
 	String SCORE_CONSIGN_REGISTER = "score:consign:register";
 
 	/**
-	 * 定时时间
+	 * 场次 - 定时时间
 	 */
 	String TASK_SCHEDULING_TIME = "default:task:time";
 
+	/**
+	 * 预授权退款(解冻) 定时时间
+	 */
+	String TASK_GRANT_TIME = "task:grant:time";
+
 
 	/**
 	 * 增益时间

+ 6 - 4
src/main/java/org/springblade/modules/api/task/ConsignSchedulingTask.java

@@ -15,6 +15,7 @@ import org.springblade.modules.shopping.entity.Consign;
 import org.springblade.modules.shopping.entity.ConsignConfig;
 import org.springblade.modules.shopping.service.IConsignConfigService;
 import org.springblade.modules.shopping.service.IConsignService;
+import org.springblade.modules.shopping.wrapper.ConsignWrapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.Trigger;
 import org.springframework.scheduling.TriggerContext;
@@ -23,6 +24,7 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
 import org.springframework.scheduling.support.CronTrigger;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Date;
@@ -153,8 +155,7 @@ public class ConsignSchedulingTask implements SchedulingConfigurer {
 		if (list.size() > 0){
 			//通过场次Id更新用户单时间等数据
 			Consign consign = list.get(0);
-			Double ratioPrice = NumberUtil.mul(consign.getConsignPrice(),ratio);
-			Double consignPrice = NumberUtil.add(consign.getConsignPrice(),ratioPrice);
+			Double consignPrice = ConsignWrapper.build().getPrice(consign.getConsignPrice());
 			Consign sign = new Consign();
 			sign.setStartTime(startDate);
 			sign.setEndTime(endTime);
@@ -191,8 +192,9 @@ public class ConsignSchedulingTask implements SchedulingConfigurer {
 			sign.setId(null);
 			sign.setStartTime(startDate);
 			sign.setEndTime(endTime);
-			Double ratioPrice = NumberUtil.mul(consign.getConsignPrice(),ratio);
-			Double consignPrice = NumberUtil.add(consign.getConsignPrice(),ratioPrice);
+			Double consignPrice = ConsignWrapper.build().getPrice(consign.getConsignPrice());
+			//Double price = NumberUtil.add(consign.getConsignPrice(),ratioPrice);// 0.105
+			//Double consignPrice = NumberUtil.roundDown(price,2);
 			sign.setConsignPrice(consignPrice);
 			sign.setNowStock(sign.getTotalNum()); //初始金额等于总金额
 			sign.setObtainPrice(consign.getObtainPrice());//进货价 == 取得价

+ 14 - 5
src/main/java/org/springblade/modules/api/task/GrantSchedulingTask.java

@@ -4,6 +4,9 @@ import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springblade.common.cache.ParamCache;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.modules.api.service.ITradeService;
 import org.springblade.modules.finance.entity.OrderGrant;
 import org.springblade.modules.finance.service.IOrderGrantService;
@@ -44,9 +47,9 @@ public class GrantSchedulingTask implements SchedulingConfigurer {
 		Runnable task = new Runnable() {
 			@Override
 			public void run() {
-				log.info(TASK_NAME + "定时任务时间: " + LocalDateTime.now());
-				alipayUnfreeze();
 				log.info(TASK_NAME + "定时任务开始: " + LocalDateTime.now());
+				alipayUnfreeze();
+				log.info(TASK_NAME + "定时任务结束: " + LocalDateTime.now());
 			}
 		};
 
@@ -58,7 +61,13 @@ public class GrantSchedulingTask implements SchedulingConfigurer {
 				//cron = timerQueryMapper.getCronTime();
 				//0/5 * * * * ?
 				//0 0 1 * * ?
-				String cron = "0 22 1 * * ?";
+				int taskTime = Integer.parseInt(ParamCache.getValue(CommonConstant.TASK_GRANT_TIME));//分钟
+				if(StringUtil.isEmpty(taskTime)){
+					taskTime = 10;
+				}
+				log.info(TASK_NAME + "定时时间间隔: " + taskTime);
+				String cron = "0 0/" + taskTime + " * * * ?";
+				//String cron = "0 0/5 * * * ?";
 				CronTrigger trigger = new CronTrigger(cron);
 				return trigger.nextExecutionTime(triggerContext);
 			}
@@ -68,11 +77,11 @@ public class GrantSchedulingTask implements SchedulingConfigurer {
 
 	private void alipayUnfreeze(){
 		String ymd = DateUtil.format(DateUtil.offsetDay(DateUtil.date(), -1), PATTERN_DATE);
-		log.info("上一天的日期:" + ymd);
 		List<OrderGrant> list = orderGrantService.list(Wrappers.<OrderGrant>lambdaQuery()
 			.eq(OrderGrant::getStatus, 1)
-			.eq(OrderGrant::getDataDate, ymd)
+			//.eq(OrderGrant::getDataDate, ymd)
 			.gt(OrderGrant::getNowNum, 0)
+			.last(" AND EXISTS (select 1 from t_consign_config f where f.is_enabled = 1 and f.id = bat_no and f.end_time < NOW()) ")
 		);
 		log.info("已授权冻结的数据:" + list.size());
 		if (list.size() > 0){

+ 3 - 2
src/main/java/org/springblade/modules/finance/controller/PlatformAuthorizationController.java

@@ -28,6 +28,7 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.finance.entity.PlatformAuthorization;
+import org.springblade.modules.finance.wrapper.PlatformAuthorizationWrapper;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.modules.finance.vo.PlatformAuthorizationVO;
@@ -65,9 +66,9 @@ public class PlatformAuthorizationController extends BladeController {
 	@GetMapping("/list")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入platformAuthorization")
-	public R<IPage<PlatformAuthorization>> list(PlatformAuthorization platformAuthorization, Query query) {
+	public R<IPage<PlatformAuthorizationVO>> list(PlatformAuthorization platformAuthorization, Query query) {
 		IPage<PlatformAuthorization> pages = platformAuthorizationService.page(Condition.getPage(query), Condition.getQueryWrapper(platformAuthorization));
-		return R.data(pages);
+		return R.data(PlatformAuthorizationWrapper.build().pageVO(pages));
 	}
 
 	/**

+ 4 - 0
src/main/java/org/springblade/modules/finance/entity/PlatformAuthorization.java

@@ -106,4 +106,8 @@ public class PlatformAuthorization implements Serializable {
 	 */
 	@ApiModelProperty(value = "创建时间")
 	private Date createTime;
+
+	@TableLogic
+	@ApiModelProperty(value = "删除标识   0正常  1逻辑删除")
+	private Integer isDeleted;
 }

+ 10 - 0
src/main/java/org/springblade/modules/finance/vo/PlatformAuthorizationVO.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.finance.vo;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import io.swagger.annotations.ApiModel;
@@ -33,4 +34,13 @@ import org.springblade.modules.finance.entity.PlatformAuthorization;
 public class PlatformAuthorizationVO extends PlatformAuthorization {
 	private static final long serialVersionUID = 1L;
 
+	@ApiModelProperty(value = "授权状态:0、未授权,1、已授权,2已解冻")
+	private String stateDisplayName;
+
+	@ApiModelProperty(value = "账号")
+	private String account;
+
+	@ApiModelProperty(value = "姓名")
+	private String realName;
+
 }

+ 64 - 0
src/main/java/org/springblade/modules/finance/wrapper/PlatformAuthorizationWrapper.java

@@ -0,0 +1,64 @@
+/*
+ *      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.modules.finance.wrapper;
+
+import cn.hutool.core.util.ObjectUtil;
+import org.springblade.common.cache.DictBizCache;
+import org.springblade.common.enums.DictBizEnum;
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.modules.finance.entity.OrderGrant;
+import org.springblade.modules.finance.entity.PlatformAuthorization;
+import org.springblade.modules.finance.service.IOrderGrantService;
+import org.springblade.modules.finance.vo.OrderGrantVO;
+import org.springblade.modules.finance.vo.PlatformAuthorizationVO;
+import org.springblade.modules.system.entity.User;
+import org.springblade.modules.system.service.IUserService;
+
+import java.util.Objects;
+
+/**
+ * 包装类,返回视图层所需的字段
+ *
+ * @author Chill
+ */
+public class PlatformAuthorizationWrapper extends BaseEntityWrapper<PlatformAuthorization, PlatformAuthorizationVO> {
+
+	public static PlatformAuthorizationWrapper build() {
+		return new PlatformAuthorizationWrapper();
+	}
+
+	public static IUserService userService;
+
+	static {
+		userService = SpringUtil.getBean(IUserService.class);
+	}
+
+	@Override
+	public PlatformAuthorizationVO entityVO(PlatformAuthorization entity) {
+		PlatformAuthorizationVO vo = Objects.requireNonNull(BeanUtil.copy(entity, PlatformAuthorizationVO.class));
+		User user = userService.getById(vo.getCreateUserId());
+		if (ObjectUtil.isNotNull(user)){
+			vo.setAccount(user.getAccount());
+			vo.setRealName(user.getRealName());
+		}
+		vo.setStateDisplayName(DictBizCache.getValue(DictBizEnum.AUTH_STATE,vo.getState()));
+		return vo;
+	}
+
+}

+ 21 - 2
src/main/java/org/springblade/modules/platform/controller/UserAppController.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.platform.controller;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
@@ -26,6 +27,7 @@ import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.platform.entity.UserCardInfo;
 import org.springblade.modules.platform.service.IUserCardInfoService;
@@ -37,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 用户列表 控制器
@@ -67,8 +70,24 @@ public class UserAppController extends BladeController {
 	@GetMapping("/list")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入userApp")
-	public R<IPage<UserAppVO>> list(UserApp userApp, Query query) {
-		IPage<UserApp> pages = userApp.selectPage(Condition.getPage(query), Condition.getQueryWrapper(userApp));
+	public R<IPage<UserAppVO>> list(UserAppVO vo, Query query) {
+		UserApp userApp = new UserApp();
+		UserApp param = Objects.requireNonNull(BeanUtil.copy(vo, UserApp.class));
+		String sql = " and EXISTS (SELECT 1 FROM blade_user u WHERE u.id = user_id";
+		if (ObjectUtil.isNotNull(vo.getUsername())){
+			sql = sql + " and account like concat(concat('%', " + vo.getUsername() + "),'%') ";
+		}
+		if (ObjectUtil.isNotNull(vo.getRealName())){
+			sql = sql + " and real_name like concat(concat('%', " + vo.getRealName() + "),'%') ";
+		}
+		if (ObjectUtil.isNotNull(vo.getCode())){
+			sql = sql + " and code like concat(concat('%', " + vo.getCode() + "),'%') ";
+		}
+		sql = sql + ")";
+		IPage<UserApp> pages = userApp.selectPage(Condition.getPage(query),
+			Condition.getQueryWrapper(param)
+				.ne("user_id", "1") //last前需要加ne
+				.last(sql));
 		return R.data(UserAppWrapper.build().pageVO(pages));
 	}
 

+ 18 - 3
src/main/java/org/springblade/modules/shopping/wrapper/ConsignWrapper.java

@@ -40,6 +40,7 @@ import org.springblade.modules.shopping.vo.ConsignVO;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.service.IUserService;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Objects;
 
@@ -105,8 +106,9 @@ public class ConsignWrapper extends BaseEntityWrapper<Consign, ConsignVO> {
 		}else {
 			ratio = Double.valueOf(ParamCache.getValue(CommonConstant.DEFAULT_CONDIGN_RATIO_T1));
 		}*/
-		Double ratioPrice = NumberUtil.mul(price, ratio);
-		return NumberUtil.add(price, ratioPrice);
+		double ratioPrice = NumberUtil.mul(price, ratio); //0.1 * 0.05 = 0.005
+		return  new BigDecimal(price).add(new BigDecimal(ratioPrice))
+			.setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
 	}
 
 	/**
@@ -116,8 +118,21 @@ public class ConsignWrapper extends BaseEntityWrapper<Consign, ConsignVO> {
 	 * @return Double
 	 */
 	public Double getScore(Double score){
-		Double ratio = Double.valueOf(ParamCache.getValue(CommonConstant.DEFAULT_SCORE_RATIO));;
+		Double ratio = Double.valueOf(ParamCache.getValue(CommonConstant.DEFAULT_SCORE_RATIO));
 		return NumberUtil.roundDown(NumberUtil.mul(score, ratio) , 2).doubleValue();
 	}
 
+	/**
+	 * 获取寄售手续费
+	 *
+	 * @param consignPrice
+	 * @return Double
+	 */
+	public Double getPrice(Double consignPrice){
+		Double ratio = Double.valueOf(ParamCache.getValue(CommonConstant.DEFAULT_CONDIGN_RATIO_T1));
+		double ratioPrice = NumberUtil.mul(consignPrice, ratio); //0.1 * 0.05 = 0.005
+		return  new BigDecimal(consignPrice).add(new BigDecimal(ratioPrice))
+			.setScale(2,BigDecimal.ROUND_DOWN).doubleValue();
+	}
+
 }

+ 0 - 1
src/main/java/org/springblade/modules/system/vo/UserAppVO.java

@@ -41,7 +41,6 @@ import java.util.Date;
 public class UserAppVO extends UserApp {
 	private static final long serialVersionUID = 1L;
 
-	@JsonIgnore
 	@ApiModelProperty(value = "主键ID, 不是用户ID")
 	private Long id;