Pārlūkot izejas kodu

获取乐团班级列表不需要登录

周箭河 4 gadi atpakaļ
vecāks
revīzija
d616f3376a

+ 75 - 46
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentInstrument.java

@@ -2,55 +2,68 @@ package com.ym.mec.biz.dal.entity;
 
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+
 import java.util.Date;
 
-@ApiModel(value="com-ym-mec-biz-dal-entity-StudentInstrument")
+@ApiModel(value = "com-ym-mec-biz-dal-entity-StudentInstrument")
 public class StudentInstrument {
-    @ApiModelProperty(value="")
+    @ApiModelProperty(value = "")
     private Long id;
 
     /**
      * 学生id
      */
-    @ApiModelProperty(value="学生id")
+    @ApiModelProperty(value = "学生id")
     private Integer studentId;
 
     /**
-    * 商品id
-    */
-    @ApiModelProperty(value="商品id")
+     * 商品id
+     */
+    @ApiModelProperty(value = "商品id")
     private Integer goodsId;
 
     /**
-    * 是否月保 0-不是 1-是
-    */
-    @ApiModelProperty(value="是否月保 0-不是 1-是")
+     * 是否月保 0-不是 1-是
+     */
+    @ApiModelProperty(value = "是否月保 0-不是 1-是")
     private Integer status;
 
     /**
-    * 月保开始时间
-    */
-    @ApiModelProperty(value="月保开始时间")
+     * 月保开始时间
+     */
+    @ApiModelProperty(value = "月保开始时间")
     private Date startTime;
 
     /**
-    * 月保结束时间
-    */
-    @ApiModelProperty(value="月保结束时间")
+     * 月保结束时间
+     */
+    @ApiModelProperty(value = "月保结束时间")
     private Date endTime;
 
     /**
-    * 添加时间
-    */
-    @ApiModelProperty(value="添加时间")
+     * 添加时间
+     */
+    @ApiModelProperty(value = "添加时间")
     private Date createTime;
 
     /**
-    * 更新时间
-    */
-    @ApiModelProperty(value="更新时间")
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间")
     private Date updateTime;
 
+    @ApiModelProperty(value = "乐器名称")
+    private String goodsName;
+
+    @ApiModelProperty(value = "乐器品牌")
+    private String goodsBrand;
+
+    @ApiModelProperty(value = "乐器规格")
+    private String specification;
+
+    @ApiModelProperty(value = "乐器图片")
+    private String goodsImg;
+
     public Long getId() {
         return id;
     }
@@ -75,6 +88,47 @@ public class StudentInstrument {
         this.status = status;
     }
 
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+
+    public String getGoodsName() {
+        return goodsName;
+    }
+
+    public void setGoodsName(String goodsName) {
+        this.goodsName = goodsName;
+    }
+
+
+    public String getGoodsImg() {
+        return goodsImg;
+    }
+
+    public void setGoodsImg(String goodsImg) {
+        this.goodsImg = goodsImg;
+    }
+
+    public String getGoodsBrand() {
+        return goodsBrand;
+    }
+
+    public void setGoodsBrand(String goodsBrand) {
+        this.goodsBrand = goodsBrand;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+
     public Date getStartTime() {
         return startTime;
     }
@@ -106,29 +160,4 @@ public class StudentInstrument {
     public void setUpdateTime(Date updateTime) {
         this.updateTime = updateTime;
     }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getClass().getSimpleName());
-        sb.append(" [");
-        sb.append("Hash = ").append(hashCode());
-        sb.append(", id=").append(id);
-        sb.append(", goodsId=").append(goodsId);
-        sb.append(", status=").append(status);
-        sb.append(", startTime=").append(startTime);
-        sb.append(", endTime=").append(endTime);
-        sb.append(", createTime=").append(createTime);
-        sb.append(", updateTime=").append(updateTime);
-        sb.append("]");
-        return sb.toString();
-    }
-
-    public Integer getStudentId() {
-        return studentId;
-    }
-
-    public void setStudentId(Integer studentId) {
-        this.studentId = studentId;
-    }
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentInstrumentService.java

@@ -4,6 +4,15 @@ import com.ym.mec.biz.dal.entity.StudentInstrument;
 
 import com.ym.mec.common.service.BaseService;
 
+import java.math.BigDecimal;
+import java.util.Map;
+
 public interface StudentInstrumentService extends BaseService<Long, StudentInstrument> {
 
+    /**
+     * 乐保支付
+     * @param id
+     * @return
+     */
+    Map pay(Long id, BigDecimal amount);
 }

+ 102 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -1,22 +1,123 @@
 package com.ym.mec.biz.service.impl;
 
 
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
-import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.GoodsType;
+import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.service.PayService;
 import com.ym.mec.biz.service.StudentInstrumentService;
+import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
 @Service
 public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentInstrument> implements StudentInstrumentService {
 
     @Autowired
     private StudentInstrumentDao studentInstrumentDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
+    @Autowired
+    private PayService payService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @Override
     public BaseDAO<Long, StudentInstrument> getDAO() {
         return studentInstrumentDao;
     }
+
+    @Override
+    public Map pay(Long id,BigDecimal amount) {
+        StudentInstrument studentInstrument = studentInstrumentDao.get(id);
+        if (studentInstrument == null) {
+            throw new BizException("所选乐器不存在,请核查");
+        }
+        Integer userId = studentInstrument.getStudentId();
+        BigDecimal orderAmount = new BigDecimal(400);
+
+
+        if (amount.compareTo(orderAmount) != 0) {
+            throw new BizException("商品价格不符");
+        }
+
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+
+        String channelType = "";
+
+        Date date = new Date();
+        BigDecimal balance = BigDecimal.ZERO;
+        if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+            if (userCashAccount == null) {
+                throw new BizException("用户账户找不到");
+            }
+            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
+                balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
+                amount = amount.subtract(balance);
+                studentPaymentOrder.setPaymentChannel("BALANCE");
+                studentPaymentOrder.setActualAmount(amount);
+                studentPaymentOrder.setBalancePaymentAmount(balance);
+                sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团报名");
+            }
+        }
+        studentPaymentOrder.setPaymentChannel("BALANCE");
+        studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
+        studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
+        studentPaymentOrder.setOrganId(musicGroup.getOrganId());
+        studentPaymentOrder.setRoutingOrganId(musicGroup.getOrganId());
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.update(studentPaymentOrder);
+        studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
+
+        if (amount.compareTo(BigDecimal.ZERO) == 0) {
+            studentPaymentRouteOrderService.addRouteOrder(orderNo, musicGroup.getOrganId(), balance);
+            Map<String, String> notifyMap = new HashMap<>();
+            notifyMap.put("tradeState", "1");
+            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+            notifyMap.put("channelType", channelType);
+            notifyMap.put("orderNo", "");
+            studentPaymentOrderService.updateOrder(notifyMap);
+            return notifyMap;
+        }
+
+        String orderSubject = "乐保服务";
+        String receiver = "maintenance";
+
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+
+        Map payMap = payService.getPayMap(
+                amount,
+                balance,
+                orderNo,
+                baseApiUrl + "/api-student/studentOrder/notify",
+                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
+                orderSubject,
+                orderSubject,
+                musicGroup.getOrganId(),
+                receiver
+        );
+
+        studentPaymentOrder.setOrganId(musicGroup.getOrganId());
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.update(studentPaymentOrder);
+        return payMap;
+    }
 }

+ 31 - 6
mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ym.mec.biz.dal.dao.StudentInstrumentDao">
-  <resultMap id="StudentInstrument" type="com.ym.mec.biz.dal.entity.StudentInstrument" extends="com.ym.mec.biz.dal.dao.GoodsDao.Goods">
+  <resultMap id="StudentInstrument" type="com.ym.mec.biz.dal.entity.StudentInstrument">
     <!--@mbg.generated-->
     <!--@Table student_instrument-->
     <id column="id_" property="id" />
@@ -12,10 +12,14 @@
     <result column="end_time_" property="endTime" />
     <result column="create_time_" property="createTime" />
     <result column="update_time" property="updateTime" />
+    <result column="goods_name_" property="goodsName" />
+    <result column="specification_" property="specification" />
+    <result column="goods_brand_" property="goodsBrand" />
+    <result column="goods_img_" property="goodsImg" />
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id_, goods_id_,student_id_, status_, start_time_, end_time_, create_time_, update_time
+    id_,student_id_, goods_id_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time
   </sql>
   <select id="get" parameterType="java.lang.Integer" resultMap="StudentInstrument">
     <!--@mbg.generated-->
@@ -32,9 +36,9 @@
   
   <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument" useGeneratedKeys="true">
     <!--@mbg.generated-->
-    insert into student_instrument (student_id,goods_id_, status_, start_time_, end_time_, create_time_, update_time
+    insert into student_instrument (student_id_,goods_id_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time
       )
-    values (#{studentId},#{goodsId}, #{status}, #{startTime}, #{endTime}, #{createTime}, #{updateTime}
+    values (#{studentId},#{goodsId},#{goodsName},#{goodsBrand},#{specification},#{goodsImg}, #{status}, #{startTime}, #{endTime}, #{createTime}, #{updateTime}
       )
   </insert>
   <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument">
@@ -44,6 +48,18 @@
       <if test="goodsId != null">
         goods_id_ = #{goodsId},
       </if>
+      <if test="goodsName != null">
+        goods_name_ = #{goodsName},
+      </if>
+      <if test="goodsBrand != null">
+        goods_brand_ = #{goodsBrand},
+      </if>
+      <if test="specification != null">
+        specification_ = #{specification},
+      </if>
+      <if test="goodsImg != null">
+        goods_img_ = #{goodsImg},
+      </if>
       <if test="status != null">
         status_ = #{status},
       </if>
@@ -71,8 +87,8 @@
 
   <!-- 分页查询 -->
   <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
-    SELECT * FROM student_instrument si
-    LEFT JOIN goods g ON g.id_ = si.goods_id_
+    SELECT * FROM student_instrument
+    <include refid="queryPageSql"/>
     <include refid="global.limit"/>
   </select>
 
@@ -80,6 +96,15 @@
   <select id="queryCount" resultType="int">
     SELECT COUNT(*)
     FROM student_instrument
+    <include refid="queryPageSql"/>
   </select>
 
+  <sql id="queryPageSql">
+    <where>
+      <if test="studentId != null">
+        AND student_id_ = #{studentId}
+      </if>
+    </where>
+  </sql>
+
 </mapper>

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

@@ -44,6 +44,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
                 "/contracts/queryProduceContract",
                 "/repair/studentPaymentGoodsOrder",
                 "/studentCompetition/getWinnerList",
+                "/studentInstrument/getList",
                 "/studentCompetition/get","/musicGroup/preRegister").permitAll().anyRequest().authenticated().and().httpBasic();
     }
 

+ 7 - 9
mec-student/src/main/java/com/ym/mec/student/controller/StudentInstrumentController.java

@@ -33,20 +33,18 @@ public class StudentInstrumentController extends BaseController {
     @ApiOperation(value = "获取乐器与月保列表")
     @GetMapping("/getList")
     public HttpResponseResult<PageInfo<StudentInstrument>> getList(StudentInstrumentQueryInfo queryInfo) {
-//        SysUser user = sysUserFeignService.queryUserInfo();
-//        if(user == null || user.getId()==null){
-//            return failed(HttpStatus.FORBIDDEN,"请登录");
-//        }
-//        queryInfo.setStudentId(user.getId());
-        queryInfo.setStudentId(2111835);
-
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || user.getId() == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        queryInfo.setStudentId(user.getId());
         return succeed(studentInstrumentService.queryPage(queryInfo));
     }
 
     @ApiOperation(value = "乐保支付")
     @PostMapping("/pay")
-    @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "RegisterPayDto")})
-    public HttpResponseResult pay(@RequestBody RegisterPayDto registerPayDto) {
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "开通月保的乐器记录id", required = true, dataType = "int")})
+    public HttpResponseResult pay(Long id) {
         return null;
     }
 }