|  | @@ -4,8 +4,13 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.RegisterPayDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.MusicGroupService;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.Goods;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.StudentRegistration;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.GoodsType;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
	
		
			
				|  | @@ -13,13 +18,12 @@ import io.swagger.annotations.ApiImplicitParam;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiImplicitParams;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.GetMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | -import org.springframework.web.bind.annotation.RestController;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import javax.xml.soap.Name;
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.util.Date;
 | 
	
		
			
				|  |  |  import java.util.LinkedHashMap;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @RequestMapping("musicGroup")
 | 
	
	
		
			
				|  | @@ -33,6 +37,14 @@ public class MusicGroupController extends BaseController {
 | 
	
		
			
				|  |  |      private MusicGroupService musicGroupService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentRegistrationService studentRegistrationService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private GoodsService goodsService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentPaymentOrderService studentPaymentOrderService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation("获取学生所在乐团列表")
 | 
	
		
			
				|  |  |      @GetMapping(value = "/queryUserMusicGroups")
 | 
	
	
		
			
				|  | @@ -76,9 +88,53 @@ public class MusicGroupController extends BaseController {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @ApiOperation(value = "乐团报名支付")
 | 
	
		
			
				|  |  | -    @GetMapping("/pay")
 | 
	
		
			
				|  |  | +    @PostMapping("/pay")
 | 
	
		
			
				|  |  |      @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "Integer")})
 | 
	
		
			
				|  |  | -    public HttpResponseResult pay(RegisterPayDto registerPayDto) {
 | 
	
		
			
				|  |  | +    public HttpResponseResult pay(@RequestBody RegisterPayDto registerPayDto) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | +        Integer userId = sysUser.getId();
 | 
	
		
			
				|  |  | +        StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
 | 
	
		
			
				|  |  | +        if (!studentRegistration.getUserId().equals(userId)) {
 | 
	
		
			
				|  |  | +            return failed("报名信息有误,请核查");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        BigDecimal amount = registerPayDto.getAmount();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        BigDecimal orderAmount = new BigDecimal("0");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //获取课程价格
 | 
	
		
			
				|  |  | +        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
 | 
	
		
			
				|  |  | +        orderAmount.add(musicOneSubjectClassPlan.getFee());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //乐器及打包辅件
 | 
	
		
			
				|  |  | +        if (registerPayDto.getGoodsGroupIds() != null) {
 | 
	
		
			
				|  |  | +            List<MusicGroupSubjectGoodsGroup> goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
 | 
	
		
			
				|  |  | +            goodsGroups.forEach(goodsGroup -> {
 | 
	
		
			
				|  |  | +                //辅件价格
 | 
	
		
			
				|  |  | +                if (goodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
 | 
	
		
			
				|  |  | +                    orderAmount.add(goodsGroup.getPrice());
 | 
	
		
			
				|  |  | +                    return;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {//租赁
 | 
	
		
			
				|  |  | +                    orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
 | 
	
		
			
				|  |  | +                } else if (musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
 | 
	
		
			
				|  |  | +                    orderAmount.add(goodsGroup.getPrice()).subtract(goodsGroup.getRemissionCourseFee());//团购减免课程费用
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //单独辅件
 | 
	
		
			
				|  |  | +        if (registerPayDto.getGoodsIds() != null) {
 | 
	
		
			
				|  |  | +            List<Goods> goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
 | 
	
		
			
				|  |  | +            goodsList.forEach(goods -> {
 | 
	
		
			
				|  |  | +                orderAmount.add(goods.getGroupPurchasePrice());
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (amount.compareTo(orderAmount) != 0) {
 | 
	
		
			
				|  |  | +            return failed("商品价格不符");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          Map<String, Object> rqMap = new LinkedHashMap<String, Object>();
 | 
	
		
			
				|  |  |          rqMap.put("merNo", "07654478");
 | 
	
		
			
				|  |  |          rqMap.put("version", "v1");
 |