|
@@ -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;
|
|
@@ -14,12 +19,16 @@ 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.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
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")
|
|
@@ -27,12 +36,18 @@ import java.util.Map;
|
|
|
@RestController
|
|
|
public class MusicGroupController extends BaseController {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
@Autowired
|
|
|
private MusicGroupService musicGroupService;
|
|
|
@Autowired
|
|
|
private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
|
+ @Autowired
|
|
|
+ private StudentRegistrationService studentRegistrationService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
|
|
|
+ @Autowired
|
|
|
+ private GoodsService goodsService;
|
|
|
|
|
|
@ApiOperation("获取学生所在乐团列表")
|
|
|
@GetMapping(value = "/queryUserMusicGroups")
|
|
@@ -78,7 +93,50 @@ public class MusicGroupController extends BaseController {
|
|
|
@ApiOperation(value = "乐团报名支付")
|
|
|
@GetMapping("/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();
|
|
|
+ StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
|
|
|
+ if (!studentRegistration.getUserId().equals(sysUser.getId())) {
|
|
|
+ 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");
|