Sfoglia il codice sorgente

add 乐器置换支付接口

周箭河 4 anni fa
parent
commit
782e0142bd

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ReplacementInstrumentActivityDao.java

@@ -13,7 +13,7 @@ import com.ym.mec.common.dal.BaseDAO;
 public interface ReplacementInstrumentActivityDao extends BaseDAO<Integer, ReplacementInstrumentActivity> {
 public interface ReplacementInstrumentActivityDao extends BaseDAO<Integer, ReplacementInstrumentActivity> {
 
 
 
 
-    ReplacementInstrumentActivity findByUserId(@Param("cooperationOrganId") Integer cooperationOrganId, @Param("userId")Integer userId);
+    ReplacementInstrumentActivity findByUserId(@Param("cooperationOrganId") Integer cooperationOrganId, @Param("userId") Integer userId);
 
 
     List<ReplacementInstrumentActivityStatDto> queryReplacements(Map<String, Object> params);
     List<ReplacementInstrumentActivityStatDto> queryReplacements(Map<String, Object> params);
 
 
@@ -27,8 +27,17 @@ public interface ReplacementInstrumentActivityDao extends BaseDAO<Integer, Repla
 
 
     /**
     /**
      * 获取开启缴费推送的人
      * 获取开启缴费推送的人
+     *
      * @param cooperationOrganId
      * @param cooperationOrganId
      * @return
      * @return
      */
      */
     List<ReplacementInstrumentActivityStatDto> getPushUsers(@Param("cooperationOrganId") Integer cooperationOrganId);
     List<ReplacementInstrumentActivityStatDto> getPushUsers(@Param("cooperationOrganId") Integer cooperationOrganId);
+
+    /**
+     * 获取置换记录详情
+     *
+     * @param id
+     * @return
+     */
+    ReplacementInstrumentActivityStatDto getInfo(@Param("id") Integer id);
 }
 }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -398,4 +398,11 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      * @return
      * @return
      */
      */
     List<StudentPaymentOrder> getAdaPayOrdersByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
     List<StudentPaymentOrder> getAdaPayOrdersByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    /**
+     * 获取用户乐器置换的订单
+     *
+     * @return
+     */
+    StudentPaymentOrder getUserReplacementIngOrder(@Param("userId") Integer userId, @Param("replacementId") Integer replacementId);
 }
 }

+ 53 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementInstrumentActivityStatDto.java

@@ -3,6 +3,8 @@ package com.ym.mec.biz.dal.dto;
 import com.ym.mec.biz.dal.entity.ReplacementInstrument;
 import com.ym.mec.biz.dal.entity.ReplacementInstrument;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
 
 
+import java.math.BigDecimal;
+
 /**
 /**
  * @Author Joburgess
  * @Author Joburgess
  * @Date 2021/4/18 0018
  * @Date 2021/4/18 0018
@@ -17,6 +19,17 @@ public class ReplacementInstrumentActivityStatDto extends ReplacementInstrumentA
     /** 型号 */
     /** 型号 */
     private String specification;
     private String specification;
 
 
+    /** 配置 */
+    private String param;
+
+    private BigDecimal marketPrice;
+
+    private BigDecimal discountPrice;
+
+    private BigDecimal depreciationPrice;
+
+    private BigDecimal salePrice;
+
     public String getSubjectName() {
     public String getSubjectName() {
         return subjectName;
         return subjectName;
     }
     }
@@ -40,4 +53,44 @@ public class ReplacementInstrumentActivityStatDto extends ReplacementInstrumentA
     public void setSpecification(String specification) {
     public void setSpecification(String specification) {
         this.specification = specification;
         this.specification = specification;
     }
     }
+
+    public BigDecimal getMarketPrice() {
+        return marketPrice;
+    }
+
+    public void setMarketPrice(BigDecimal marketPrice) {
+        this.marketPrice = marketPrice;
+    }
+
+    public BigDecimal getDiscountPrice() {
+        return discountPrice;
+    }
+
+    public void setDiscountPrice(BigDecimal discountPrice) {
+        this.discountPrice = discountPrice;
+    }
+
+    public BigDecimal getDepreciationPrice() {
+        return depreciationPrice;
+    }
+
+    public void setDepreciationPrice(BigDecimal depreciationPrice) {
+        this.depreciationPrice = depreciationPrice;
+    }
+
+    public BigDecimal getSalePrice() {
+        return salePrice;
+    }
+
+    public void setSalePrice(BigDecimal salePrice) {
+        this.salePrice = salePrice;
+    }
+
+    public String getParam() {
+        return param;
+    }
+
+    public void setParam(String param) {
+        this.param = param;
+    }
 }
 }

+ 12 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementPayDto.java

@@ -12,10 +12,10 @@ public class ReplacementPayDto {
     private BigDecimal amount;
     private BigDecimal amount;
 
 
     @ApiModelProperty(value = "是否使用余额", required = true)
     @ApiModelProperty(value = "是否使用余额", required = true)
-    private Boolean isUseBalance = false;
+    private Boolean useBalance = false;
 
 
     @ApiModelProperty(value = "重新支付", required = true)
     @ApiModelProperty(value = "重新支付", required = true)
-    private Boolean isRePay = false;
+    private Boolean rePay = false;
 
 
     public Integer getId() {
     public Integer getId() {
         return id;
         return id;
@@ -34,10 +34,18 @@ public class ReplacementPayDto {
     }
     }
 
 
     public Boolean getUseBalance() {
     public Boolean getUseBalance() {
-        return isUseBalance;
+        return useBalance;
     }
     }
 
 
     public void setUseBalance(Boolean useBalance) {
     public void setUseBalance(Boolean useBalance) {
-        isUseBalance = useBalance;
+        this.useBalance = useBalance;
+    }
+
+    public Boolean getRePay() {
+        return rePay;
+    }
+
+    public void setRePay(Boolean rePay) {
+        this.rePay = rePay;
     }
     }
 }
 }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ReplacementInstrumentActivityService.java

@@ -33,4 +33,11 @@ public interface ReplacementInstrumentActivityService extends BaseService<Intege
      */
      */
     Boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
     Boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
 
 
+    /**
+     * 获取置换的详情
+     * @param id
+     * @return
+     */
+    ReplacementInstrumentActivityStatDto getInfo(Integer id);
+
 }
 }

+ 152 - 126
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -21,130 +21,156 @@ import com.ym.mec.common.service.BaseService;
 
 
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {
 
 
-	/**
-	 * 查询商品列表
-	 * @param musicGroupId
-	 * @param type
-	 * @return
-	 */
-	List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type);
-
-	/**
-	 * 查询订单列表
-	 * @param groupType
-	 * @param musicGroupId
-	 * @param userId
-	 * @param status
-	 * @param type
-	 * @return
-	 */
-	List<StudentPaymentOrder> queryByCondition(GroupType groupType, String musicGroupId, Integer userId, DealStatusEnum status, OrderTypeEnum type);
-
-	/**
-	 * 查询报名缴费订单
-	 * @param musicGroupId
-	 * @param status
-	 * @return
-	 */
-	StudentPaymentOrder findMusicGroupApplyOrderByStatus(Integer userId, String musicGroupId, DealStatusEnum status);
-
-	/**
-	 * 根据orderNo查询订单
-	 * @param orderNo
-	 * @return
-	 */
-	StudentPaymentOrder findOrderByOrderNo(String orderNo);
-
-	/**
-	 * 查找支付成功和支付中订单
-	 * @return
-	 */
-	int findPayOrderNum();
-
-	/**
-	 * 查询支付中订单
-	 *
-	 * @param status
-	 * @return
-	 */
-	List<StudentPaymentOrder> findOrdersByStatus(DealStatusEnum status, String paymentChannel);
-
-	/**
-	 * 查询支付中超时的订单
-	 * @param orderNoList
-	 * @param status
-	 * @param beforeTime
-	 * @return
-	 */
-	List<StudentPaymentOrder> findOrdersOverTime(List<String> orderNoList, DealStatusEnum status, Date beforeTime);
-
-	void queryOrderStatus() throws Exception;
-
-	void updateOrder(Map<String, String> rpMap) throws Exception;
-
-	/**
-	 * 获取零星订单
-	 * @param userId
-	 * @param sporadicId
-	 * @param sporadic
-	 * @param status
-	 * @return
-	 */
-	Integer findOrderByGroupType(Integer userId, Integer sporadicId, String sporadic, DealStatusEnum status);
-
-	List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params);
-
-	/**
-	 * 获取零星收费订单列表
-	 * @param queryInfo
-	 * @return
-	 */
-	PageInfo<SporadicChargeInfoDto> sporadicQueryPage(SporadicOrderQueryInfo queryInfo);
-
-
-	StudentPaymentOrder getOrderMoneyAmount(StudentPaymentOrderQueryInfo queryInfo);
-
-
-	PageInfoOrder<StudentPaymentOrderDto> OrderQueryPage(StudentPaymentOrderQueryInfo queryInfo);
-
-
-	/**
-	 * 获取订单第三方状态
-	 * @param id
-	 * @return
-	 */
-	Boolean getOrderStatus(Long id) throws Exception;
-
-	/**
-	 * 获取分部支付成功支付中订单数量
-	 * @param organId
-	 * @return
-	 */
-	Integer findOrganPayOrderNum(Integer organId);
-
-	/**
-	 * 获取用户某种类型的订单
-	 * @param userId
-	 * @param type
-	 * @param status
-	 * @return
-	 */
-	List<StudentPaymentOrder> getUserOrderByType(Integer userId, OrderTypeEnum type, DealStatusEnum status);
-
-
-	/**
-	 * 从新提交分账信息
-	 * @param startTime
-	 * @param endTime
-	 * @return
-	 */
-	List<StudentPaymentOrder> reConfirmOrder(Date startTime,Date endTime);
-
-	/**
-	 * 获取学生报名的订单
-	 * @param studentId
-	 * @param musicGroupId
-	 * @return
-	 */
-	List<StudentPaymentOrderExportDto> getUserApplyOrders(Integer studentId,String musicGroupId);
+    /**
+     * 查询商品列表
+     *
+     * @param musicGroupId
+     * @param type
+     * @return
+     */
+    List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type);
+
+    /**
+     * 查询订单列表
+     *
+     * @param groupType
+     * @param musicGroupId
+     * @param userId
+     * @param status
+     * @param type
+     * @return
+     */
+    List<StudentPaymentOrder> queryByCondition(GroupType groupType, String musicGroupId, Integer userId, DealStatusEnum status, OrderTypeEnum type);
+
+    /**
+     * 查询报名缴费订单
+     *
+     * @param musicGroupId
+     * @param status
+     * @return
+     */
+    StudentPaymentOrder findMusicGroupApplyOrderByStatus(Integer userId, String musicGroupId, DealStatusEnum status);
+
+    /**
+     * 根据orderNo查询订单
+     *
+     * @param orderNo
+     * @return
+     */
+    StudentPaymentOrder findOrderByOrderNo(String orderNo);
+
+    /**
+     * 查找支付成功和支付中订单
+     *
+     * @return
+     */
+    int findPayOrderNum();
+
+    /**
+     * 查询支付中订单
+     *
+     * @param status
+     * @return
+     */
+    List<StudentPaymentOrder> findOrdersByStatus(DealStatusEnum status, String paymentChannel);
+
+    /**
+     * 查询支付中超时的订单
+     *
+     * @param orderNoList
+     * @param status
+     * @param beforeTime
+     * @return
+     */
+    List<StudentPaymentOrder> findOrdersOverTime(List<String> orderNoList, DealStatusEnum status, Date beforeTime);
+
+    void queryOrderStatus() throws Exception;
+
+    void updateOrder(Map<String, String> rpMap) throws Exception;
+
+    /**
+     * 获取零星订单
+     *
+     * @param userId
+     * @param sporadicId
+     * @param sporadic
+     * @param status
+     * @return
+     */
+    Integer findOrderByGroupType(Integer userId, Integer sporadicId, String sporadic, DealStatusEnum status);
+
+    List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params);
+
+    /**
+     * 获取零星收费订单列表
+     *
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<SporadicChargeInfoDto> sporadicQueryPage(SporadicOrderQueryInfo queryInfo);
+
+
+    StudentPaymentOrder getOrderMoneyAmount(StudentPaymentOrderQueryInfo queryInfo);
+
+
+    PageInfoOrder<StudentPaymentOrderDto> OrderQueryPage(StudentPaymentOrderQueryInfo queryInfo);
+
+
+    /**
+     * 获取订单第三方状态
+     *
+     * @param id
+     * @return
+     */
+    Boolean getOrderStatus(Long id) throws Exception;
+
+    /**
+     * 获取分部支付成功支付中订单数量
+     *
+     * @param organId
+     * @return
+     */
+    Integer findOrganPayOrderNum(Integer organId);
+
+    /**
+     * 获取用户某种类型的订单
+     *
+     * @param userId
+     * @param type
+     * @param status
+     * @return
+     */
+    List<StudentPaymentOrder> getUserOrderByType(Integer userId, OrderTypeEnum type, DealStatusEnum status);
+
+
+    /**
+     * 从新提交分账信息
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<StudentPaymentOrder> reConfirmOrder(Date startTime, Date endTime);
+
+    /**
+     * 获取学生报名的订单
+     *
+     * @param studentId
+     * @param musicGroupId
+     * @return
+     */
+    List<StudentPaymentOrderExportDto> getUserApplyOrders(Integer studentId, String musicGroupId);
+
+    /**
+     * 获取用户支付中的乐器置换订单
+     *
+     * @param userId
+     * @param replacementId
+     * @return
+     */
+    StudentPaymentOrder getUserReplacementIngOrder(Integer userId, Integer replacementId);
+
+
+    void callOrderCallBack(StudentPaymentOrder order) throws Exception;
+
 }
 }

+ 24 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java

@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 
 
 import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
 import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
 
 
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
@@ -66,7 +67,7 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     @Autowired
     @Autowired
     private SysMessageService sysMessageService;
     private SysMessageService sysMessageService;
-    
+
     @Autowired
     @Autowired
     private CooperationOrganService cooperationOrganService;
     private CooperationOrganService cooperationOrganService;
 
 
@@ -86,12 +87,12 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
         }
         }
         replacementInstrumentActivity.setUserId(sysUser.getId());
         replacementInstrumentActivity.setUserId(sysUser.getId());
         //如果用户是43分部,那么修改用户信息
         //如果用户是43分部,那么修改用户信息
-        if(sysUser.getOrganId() == 43){
-        	CooperationOrgan cooperationOrgan = cooperationOrganService.get(replacementInstrumentActivity.getCooperationOrganId());
+        if (sysUser.getOrganId() == 43) {
+            CooperationOrgan cooperationOrgan = cooperationOrganService.get(replacementInstrumentActivity.getCooperationOrganId());
             if (cooperationOrgan != null) {
             if (cooperationOrgan != null) {
-            	sysUser.setOrganId(cooperationOrgan.getOrganId());
-            	sysUser.setUpdateTime(new Date());
-            	sysUserFeignService.updateSysUser(sysUser);
+                sysUser.setOrganId(cooperationOrgan.getOrganId());
+                sysUser.setUpdateTime(new Date());
+                sysUserFeignService.updateSysUser(sysUser);
             }
             }
         }
         }
         //如果提交过调查问卷,那么覆盖之前的记录
         //如果提交过调查问卷,那么覆盖之前的记录
@@ -141,15 +142,21 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
     }
     }
 
 
     @Override
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map pay(ReplacementPayDto replacementPayDto) throws Exception {
     public Map pay(ReplacementPayDto replacementPayDto) throws Exception {
         ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityDao.getLock(replacementPayDto.getId());
         ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityDao.getLock(replacementPayDto.getId());
-        if (replacementInstrumentActivity == null) {
-            throw new BizException("乐器置换不存在,请核查");
-        }
-        if (replacementInstrumentActivity.getInstrumentsId() == null || replacementInstrumentActivity.getInstrumentsId() == 0) {
-            throw new BizException("没有置换的乐器,请核查");
-        }
         Integer userId = replacementInstrumentActivity.getUserId();
         Integer userId = replacementInstrumentActivity.getUserId();
+
+        //处理关闭订单
+        if (replacementInstrumentActivity.getPayStatus().equals(1) && replacementPayDto.getRePay()) {
+            StudentPaymentOrder oldOrder = studentPaymentOrderService.getUserReplacementIngOrder(userId, replacementInstrumentActivity.getId());
+            if (oldOrder != null) {
+                oldOrder.setStatus(DealStatusEnum.FAILED);
+                oldOrder.setMemo("用户手动关闭");
+                studentPaymentOrderService.callOrderCallBack(oldOrder);
+            }
+        }
+
         ReplacementInstrument replacementInstrument = replacementInstrumentDao.get(replacementInstrumentActivity.getInstrumentsId());
         ReplacementInstrument replacementInstrument = replacementInstrumentDao.get(replacementInstrumentActivity.getInstrumentsId());
         BigDecimal orderAmount = replacementInstrument.getSalePrice();
         BigDecimal orderAmount = replacementInstrument.getSalePrice();
         BigDecimal amount = replacementPayDto.getAmount(); //扣除余额之前的金额
         BigDecimal amount = replacementPayDto.getAmount(); //扣除余额之前的金额
@@ -326,4 +333,9 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
         }
         }
         return false;
         return false;
     }
     }
+
+    @Override
+    public ReplacementInstrumentActivityStatDto getInfo(Integer id) {
+        return replacementInstrumentActivityDao.getInfo(id);
+    }
 }
 }

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -348,7 +348,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     //        }
     //        }
 
 
     //调用相应业务回调接口
     //调用相应业务回调接口
-    private void callOrderCallBack(StudentPaymentOrder order) throws Exception {
+    public void callOrderCallBack(StudentPaymentOrder order) throws Exception {
         if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
         if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
             studentRegistrationService.updateApplyOrder(order);
             studentRegistrationService.updateApplyOrder(order);
         } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
         } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
@@ -537,4 +537,9 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         }
         return orders;
         return orders;
     }
     }
+
+    @Override
+    public StudentPaymentOrder getUserReplacementIngOrder(Integer userId, Integer replacementId) {
+        return studentPaymentOrderDao.getUserReplacementIngOrder(userId, replacementId);
+    }
 }
 }

+ 13 - 0
mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentActivityMapper.xml

@@ -30,6 +30,11 @@
         <result property="subjectName" column="subject_name_"/>
         <result property="subjectName" column="subject_name_"/>
         <result property="brand" column="brand_"/>
         <result property="brand" column="brand_"/>
         <result property="specification" column="specification_"/>
         <result property="specification" column="specification_"/>
+        <result property="param" column="param_"/>
+        <result property="marketPrice" column="market_price_"/>
+        <result property="discountPrice" column="discount_price_"/>
+        <result property="depreciationPrice" column="depreciation_price_"/>
+        <result property="salePrice" column="sale_price_"/>
     </resultMap>
     </resultMap>
 
 
     <!-- 根据主键查询一条记录 -->
     <!-- 根据主键查询一条记录 -->
@@ -202,4 +207,12 @@
         WHERE cooperation_organ_id_ = #{cooperationOrganId}
         WHERE cooperation_organ_id_ = #{cooperationOrganId}
         AND open_flag_ = 0 AND instruments_id_ > 0
         AND open_flag_ = 0 AND instruments_id_ > 0
     </select>
     </select>
+
+    <select id="getInfo" resultMap="ReplacementInstrumentActivityStatDto">
+        SELECT ria.*,ri.brand_,ri.specification_,ri.param_,ri.market_price_,ri.discount_price_,ri.depreciation_price_,
+        ri.sale_price_,s.name_ subject_name_ FROM replacement_instrument_activity ria
+        LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
+        LEFT JOIN subject s on s.id_ = ri.subject_id_
+        WHERE ria.id_ = #{id}
+    </select>
 </mapper>
 </mapper>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -875,4 +875,8 @@
     <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
     <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
         SELECT * FROM student_payment_order WHERE pay_time_ >= #{startTime} AND pay_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
         SELECT * FROM student_payment_order WHERE pay_time_ >= #{startTime} AND pay_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
     </select>
     </select>
+
+    <select id="getUserReplacementIngOrder" resultMap="StudentPaymentOrder">
+        SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND music_group_id_ = #{replacementId} AND status_ = 'ING' LIMIT 1
+    </select>
 </mapper>
 </mapper>

+ 36 - 0
mec-student/src/main/java/com/ym/mec/student/controller/ReplacementInstrumentActivityController.java

@@ -2,6 +2,7 @@ package com.ym.mec.student.controller;
 
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
 import com.ym.mec.biz.dal.dto.ReplacementPayDto;
 import com.ym.mec.biz.dal.dto.ReplacementPayDto;
 import com.ym.mec.biz.dal.entity.CooperationOrgan;
 import com.ym.mec.biz.dal.entity.CooperationOrgan;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
@@ -96,10 +97,45 @@ public class ReplacementInstrumentActivityController extends BaseController {
         return succeed(replacementInstrumentActivityService.get(id));
         return succeed(replacementInstrumentActivityService.get(id));
     }
     }
 
 
+    @ApiOperation(value = "获取置换的详情")
+    @GetMapping("/getInfo")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "置换id", required = true, dataType = "int")})
+    public HttpResponseResult<ReplacementInstrumentActivityStatDto> getInfo(Integer id) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败,请重新登陆");
+        }
+        return succeed(replacementInstrumentActivityService.getInfo(id));
+    }
+
     @ApiOperation(value = "置换支付")
     @ApiOperation(value = "置换支付")
     @PostMapping("/pay")
     @PostMapping("/pay")
     @ApiImplicitParams({@ApiImplicitParam(name = "replacementPayDto", value = "支付参数", required = true, dataType = "ReplacementPayDto")})
     @ApiImplicitParams({@ApiImplicitParam(name = "replacementPayDto", value = "支付参数", required = true, dataType = "ReplacementPayDto")})
     public HttpResponseResult pay(ReplacementPayDto replacementPayDto) throws Exception {
     public HttpResponseResult pay(ReplacementPayDto replacementPayDto) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败,请重新登陆");
+        }
+        ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityService.get(replacementPayDto.getId());
+        if (replacementInstrumentActivity == null) {
+            throw new BizException("乐器置换不存在,请核查");
+        }
+        if (!sysUser.getId().equals(replacementInstrumentActivity.getUserId())) {
+            throw new BizException("该乐器置换不属于您,请核查");
+        }
+
+        if (replacementInstrumentActivity.getInstrumentsId() == null || replacementInstrumentActivity.getInstrumentsId() == 0) {
+            throw new BizException("没有置换的乐器,请核查");
+        }
+
+        //是否已支付
+        if (replacementInstrumentActivity.getPayStatus().equals(2)) {
+            return failed("您已支付成功,请勿重复支付");
+        }
+        //判断用户是否已存在订单
+        if (replacementInstrumentActivity.getPayStatus().equals(1) && !replacementPayDto.getRePay()) {
+            return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+        }
         return succeed(replacementInstrumentActivityService.pay(replacementPayDto));
         return succeed(replacementInstrumentActivityService.pay(replacementPayDto));
     }
     }
 }
 }