Browse Source

Merge remote-tracking branch 'origin/master'

hgw 3 years ago
parent
commit
0371ccd461

+ 16 - 15
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/StudentTotal.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 import java.util.Date;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -17,31 +18,31 @@ import org.springframework.format.annotation.DateTimeFormat;
 @TableName("student_total")
 @ApiModel(value = "StudentTotal对象", description = "学生统计总表")
 public class StudentTotal implements Serializable {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
     @ApiModelProperty("对应user表用户编号 ")
     @TableId(value = "user_id_")
     private Long userId;
     @ApiModelProperty("累计练习天数 ")
-	@TableField(value = "exercise_days_")
-    private Integer exerciseDays;
+    @TableField(value = "exercise_days_")
+    private Integer exerciseDays = 0;
     @ApiModelProperty("累计练习时长 ")
-	@TableField(value = "exercise_hours_")
-    private Double exerciseHours;
+    @TableField(value = "exercise_hours_")
+    private Double exerciseHours = 0.0;
     @ApiModelProperty("累计评测次数 ")
-	@TableField(value = "testing_num_")
-    private Integer testingNum;
+    @TableField(value = "testing_num_")
+    private Integer testingNum = 0;
     @ApiModelProperty("已完成课时数 ")
-	@TableField(value = "finsh_hours_")
-    private Integer finshHours;
+    @TableField(value = "finsh_hours_")
+    private Integer finshHours = 0;
     @ApiModelProperty("剩余课时数 ")
-	@TableField(value = "unfinsh_hours_")
-    private Integer unfinshHours;
+    @TableField(value = "unfinsh_hours_")
+    private Integer unfinshHours = 0;
     @ApiModelProperty("关注老师数 ")
-	@TableField(value = "star_teacher_num_")
-    private Integer starTeacherNum;
-	@TableField(value = "update_time_")
+    @TableField(value = "star_teacher_num_")
+    private Integer starTeacherNum = 0;
+    @TableField(value = "update_time_")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date updateTime;
 
     public Long getUserId() {

+ 28 - 27
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TeacherTotal.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 import java.util.Date;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -17,84 +18,84 @@ import org.springframework.format.annotation.DateTimeFormat;
 @TableName("teacher_total")
 @ApiModel(value = "TeacherTotal对象", description = "教师统计总表")
 public class TeacherTotal implements Serializable {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
     @ApiModelProperty("对应user表用户编号 ")
     @TableId(value = "user_id_")
     private Long userId;
     @ApiModelProperty("星级 ")
-	@TableField(value = "star_grade_")
-    private Double starGrade;
+    @TableField(value = "star_grade_")
+    private Double starGrade = 0.0;
     @ApiModelProperty("粉丝数 ")
-	@TableField(value = "fans_num_")
-    private Integer fansNum;
+    @TableField(value = "fans_num_")
+    private Integer fansNum = 0;
     @ApiModelProperty("已上课时 ")
-	@TableField(value = "exp_time_")
-    private Integer expTime;
+    @TableField(value = "exp_time_")
+    private Integer expTime = 0;
     @ApiModelProperty("未上课时 ")
-	@TableField(value = "un_exp_time_")
-    private Integer unExpTime;
+    @TableField(value = "un_exp_time_")
+    private Integer unExpTime = 0;
     @ApiModelProperty("是否在直播 ")
-	@TableField(value = "live_flag_")
-    private Boolean liveFlag;
-	@TableField(value = "update_time_")
+    @TableField(value = "live_flag_")
+    private Boolean liveFlag = false;
+    @TableField(value = "update_time_")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date updateTime;
 
-	public Long getUserId() {
+    public Long getUserId() {
         return userId;
     }
 
     public void setUserId(Long userId) {
         this.userId = userId;
     }
-    
-	public Double getStarGrade() {
+
+    public Double getStarGrade() {
         return starGrade;
     }
 
     public void setStarGrade(Double starGrade) {
         this.starGrade = starGrade;
     }
-    
-	public Integer getFansNum() {
+
+    public Integer getFansNum() {
         return fansNum;
     }
 
     public void setFansNum(Integer fansNum) {
         this.fansNum = fansNum;
     }
-    
-	public Integer getExpTime() {
+
+    public Integer getExpTime() {
         return expTime;
     }
 
     public void setExpTime(Integer expTime) {
         this.expTime = expTime;
     }
-    
-	public Integer getUnExpTime() {
+
+    public Integer getUnExpTime() {
         return unExpTime;
     }
 
     public void setUnExpTime(Integer unExpTime) {
         this.unExpTime = unExpTime;
     }
-    
-	public Boolean getLiveFlag() {
+
+    public Boolean getLiveFlag() {
         return liveFlag;
     }
 
     public void setLiveFlag(Boolean liveFlag) {
         this.liveFlag = liveFlag;
     }
-    
-	public Date getUpdateTime() {
+
+    public Date getUpdateTime() {
         return updateTime;
     }
 
     public void setUpdateTime(Date updateTime) {
         this.updateTime = updateTime;
     }
-    
+
 }

+ 4 - 7
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentTotalServiceImpl.java

@@ -131,19 +131,16 @@ public class StudentTotalServiceImpl extends ServiceImpl<StudentTotalDao, Studen
             }
             //处理sql
             action.accept(subList);
-            if (start >= resultList.size()) {
+            if (end >= resultList.size()) {
                 break;
             }
             start += batchSize;
         }
     }
 
-    private void saveBatch(List<StudentTotal> resultList) {
-        //todo 批量保存
-    }
-
     private void updateBatch(List<StudentTotal> resultList) {
-        //todo 批量更新
+        for (StudentTotal total : resultList) {
+            updateById(total);
+        }
     }
-
 }

+ 51 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherTotalServiceImpl.java

@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Consumer;
 import java.util.stream.Collectors;
 
 
@@ -119,6 +120,56 @@ public class TeacherTotalServiceImpl extends ServiceImpl<TeacherTotalDao, Teache
         return resultList;
     }
 
+    int batchSize = 100;
+
+    /***
+     * 批量更新插入
+     * @author liweifan
+     * @param: resultList
+     * @updateTime 2022/4/12 16:52
+     */
+    private void saveOrUpdateBatch(List<TeacherTotal> resultList) {
+        List<TeacherTotal> teacherTotals = baseMapper.selectList(Wrappers.<TeacherTotal>emptyWrapper().select("userId"));
+        Map<Long, TeacherTotal> teacherTotalMap = new HashMap<>();
+        if (!CollectionUtils.isEmpty(teacherTotals)) {
+            teacherTotals.forEach(o -> teacherTotalMap.put(o.getUserId(), o));
+        }
+        //批量插入
+        List<TeacherTotal> saveList = resultList.stream()
+                .filter(o -> null == teacherTotalMap.get(o.getUserId())).collect(Collectors.toList());
+        batchOpera(saveList, this::saveBatch);
+
+        //批量更新
+        List<TeacherTotal> updateList = resultList.stream()
+                .filter(o -> null != teacherTotalMap.get(o.getUserId())).collect(Collectors.toList());
+        batchOpera(updateList, this::updateBatch);
+    }
+
+    private void batchOpera(List<TeacherTotal> resultList, Consumer<List<TeacherTotal>> action) {
+        int start = 0;
+        while (true) {
+            int end = start + batchSize;
+            List<TeacherTotal> subList;
+            if (resultList.size() > end) {
+                subList = resultList.subList(start, start + batchSize);
+            } else {
+                subList = resultList.subList(start, resultList.size());
+            }
+            //处理sql
+            action.accept(subList);
+            if (end >= resultList.size()) {
+                break;
+            }
+            start += batchSize;
+        }
+    }
+
+    private void updateBatch(List<TeacherTotal> resultList) {
+        for (TeacherTotal total : resultList) {
+            updateById(total);
+        }
+    }
+
     @Override
     public Object getRedisValueByKey(String key) {
         return redissonClient.getBucket(key).get();

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -119,7 +119,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         if (!Objects.isNull(afterFunction)) {
             afterFunction.accept(orderVo);
         }
-        return HttpResponseResult.succeed();
+        return HttpResponseResult.succeed(orderVo);
     }
 
     @Override
@@ -127,7 +127,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
     public HttpResponseResult<OrderPayRes> orderPay(OrderPayReq payReq) {
         //查询订单
         UserOrderVo detail = detail(payReq.getOrderNo());
-        if (null == detail) {
+        if (null == detail || !payReq.getUserId().equals(detail.getUserId())) {
             return HttpResponseResult.failed("订单不存在");
         }
         if (OrderStatusEnum.WAIT_PAY.equals(detail.getStatus())) {

+ 1 - 3
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/PaymentController.java

@@ -37,8 +37,6 @@ public class PaymentController extends BaseController {
     private UserOrderService userOrderService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
-    @Autowired
-    private EmployeeService employeeService;
 
     @ApiOperation(value = "查询付款单")
     @GetMapping("/queryPayment")
@@ -57,7 +55,7 @@ public class PaymentController extends BaseController {
         if (responseResult.getStatus()) {
             Map<String, String> data = responseResult.getData();
             //绑定到用户表
-            user.setWechatId(data.get("openid"));
+            user.setWxOpenid(data.get("openid"));
             log.info("绑定用户openid,param is {}", JSONObject.toJSONString(user));
             sysUserFeignService.bindOpenId(user);
         }