ソースを参照

Merge remote-tracking branch 'origin/master'

周箭河 4 年 前
コミット
d0f4291cc1

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDao.java

@@ -281,4 +281,15 @@ public interface MusicGroupDao extends BaseDAO<String, MusicGroup> {
      * @return java.util.List<com.ym.mec.biz.dal.dto.MusicCardDto>
      */
     List<MusicCardDto> queryOrganMusicInfos(@Param("organId") Integer organId);
+
+    /**
+     * @describe 获取学员第一个教务老师
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/24
+     * @time 10:27
+     * @param userId:
+     * @return java.lang.Integer
+     */
+    Integer getFirstEduTeacherId(@Param("userId") Integer userId);
 }

+ 8 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.StudentDao;
-import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
-import com.ym.mec.biz.dal.dao.StudentRepairDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.RepairGoodsDto;
@@ -52,7 +49,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
-    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
+    private MusicGroupDao musicGroupDao;
     @Autowired
     private SysUserCashAccountService sysUserCashAccountService;
     @Autowired
@@ -109,8 +106,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     @Override
     @Transactional(rollbackFor = Exception.class,isolation = Isolation.SERIALIZABLE)
     public Map addGoodsSellOrder(StudentGoodsSell studentGoodsSell) throws Exception {
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        Integer studentId = sysUser.getId();
+        Integer studentId = studentGoodsSell.getUserId();
         List<GoodsSellDto> goodsSellDtos = studentGoodsSell.getGoodsSellDtos();
         if(goodsSellDtos == null || goodsSellDtos.size() == 0){
             throw new BizException("请选择需要购买的商品");
@@ -122,7 +118,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         SysUser student = sysUserFeignService.queryUserById(studentId);
         String orderNo = idGeneratorService.generatorId("payment") + "";
         studentGoodsSell.setOrderNo(orderNo);
-
+        if(studentGoodsSell.getTeacherId() == null){
+            //获取学员第一个教务老师
+            studentGoodsSell.setTeacherId(musicGroupDao.getFirstEduTeacherId(studentGoodsSell.getUserId()));
+        }
         List<Integer> goodsIds = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
 
 //        String[] goodsIds = goodsJson.split(",");
@@ -141,7 +140,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         if(amount.signum() < 0){
             throw new BizException("操作失败:订单金额异常");
         }
-        studentGoodsSell.setOrganId(sysUser.getOrganId());
+        studentGoodsSell.setOrganId(student.getOrganId());
         studentGoodsSell.setTotalAmount(amount);
         studentGoodsSell.setGoodsJson(JSONObject.toJSONString(goodsSellDtos));
         if(studentGoodsSell.getId() == null){

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -609,4 +609,9 @@
         </if>
         ORDER BY mg.create_time_ DESC
     </select>
+    <select id="getFirstEduTeacherId" resultType="java.lang.Integer">
+        SELECT mg.educational_teacher_id_ FROM student_registration sr
+        LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
+        WHERE user_id_ = #{userId} AND mg.status_ != 'CANCELED' AND sr.music_group_status_ != 'QUIT' LIMIT 1
+    </select>
 </mapper>

+ 4 - 4
mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java

@@ -1,5 +1,7 @@
 package com.ym.mec.student.config;
 
+import com.ym.mec.common.security.BaseAccessDeniedHandler;
+import com.ym.mec.common.security.BaseAuthenticationEntryPoint;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
@@ -8,9 +10,6 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.E
 import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
 import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
 
-import com.ym.mec.common.security.BaseAccessDeniedHandler;
-import com.ym.mec.common.security.BaseAuthenticationEntryPoint;
-
 @Configuration
 @EnableResourceServer
 @EnableGlobalMethodSecurity(prePostEnabled = true)
@@ -37,7 +36,8 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 				"/degree/*",
 				"/practiceGroup/queryOrderInfo",
 				"/systemDate/query",
-				"/organization/getOrgans").permitAll().anyRequest().authenticated().and().httpBasic();
+				"/organization/getOrgans," +
+				"/repair/addGoodsSellOrder").permitAll().anyRequest().authenticated().and().httpBasic();
 	}
 
 	@Override

+ 8 - 5
mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java

@@ -48,18 +48,21 @@ public class RepairController extends BaseController {
     @ApiOperation("添加商品销售订单")
     @PostMapping(value = "/addGoodsSellOrder")
     public HttpResponseResult addGoodsSellOrder(@RequestBody StudentGoodsSell studentGoodsSell) throws Exception {
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if (sysUser == null) {
-            throw new BizException("请登录");
+        if(studentGoodsSell.getUserId() == null){
+            SysUser sysUser = sysUserFeignService.queryUserInfo();
+            if (sysUser == null) {
+                throw new BizException("请登录");
+            }
+            studentGoodsSell.setUserId(sysUser.getId());
         }
         if (studentGoodsSell.getIsRepeatPay() == false) {
-            List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.GOODS_SELL, null, sysUser.getId(), DealStatusEnum.ING,
+            List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.GOODS_SELL, null, studentGoodsSell.getUserId(), DealStatusEnum.ING,
                     OrderTypeEnum.RENEW);
             if (list.size() > 0) {
                 return failed(HttpStatus.CONTINUE, "您有待支付的订单");
             }
         }
-        studentGoodsSell.setUserId(sysUser.getId());
+
         Map map = studentRepairService.addGoodsSellOrder(studentGoodsSell);
         if(map.containsKey("tradeState")){
             return failed(HttpStatus.CREATED, "恭喜您,购买成功!");

+ 0 - 3
mec-web/src/main/resources/application.yml

@@ -102,9 +102,6 @@ ribbon:
   ReadTimeout: 60000
   ConnectTimeout: 60000
 
-logging:
-  level:
-    com.ym.mec.auth.api.client.SysUserFeignService: INFO
 
 message:
   debugMode: true