|
@@ -4,10 +4,7 @@ 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.MusicGroupSubjectGoodsAndInfoDto;
|
|
import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
|
|
|
import com.ym.mec.biz.dal.dto.RegisterPayDto;
|
|
import com.ym.mec.biz.dal.dto.RegisterPayDto;
|
|
|
-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.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.GoodsType;
|
|
import com.ym.mec.biz.dal.enums.GoodsType;
|
|
|
import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
|
|
|
import com.ym.mec.biz.service.*;
|
|
import com.ym.mec.biz.service.*;
|
|
@@ -23,10 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.LinkedHashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
@RequestMapping("musicGroup")
|
|
@RequestMapping("musicGroup")
|
|
|
@Api(tags = "乐团服务")
|
|
@Api(tags = "乐团服务")
|
|
@@ -47,7 +41,8 @@ public class MusicGroupController extends BaseController {
|
|
|
private GoodsService goodsService;
|
|
private GoodsService goodsService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
- @Autowired PayService payService;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ PayService payService;
|
|
|
|
|
|
|
|
@ApiOperation("获取学生所在乐团列表")
|
|
@ApiOperation("获取学生所在乐团列表")
|
|
|
@GetMapping(value = "/queryUserMusicGroups")
|
|
@GetMapping(value = "/queryUserMusicGroups")
|
|
@@ -102,47 +97,56 @@ public class MusicGroupController extends BaseController {
|
|
|
return failed("报名信息有误,请核查");
|
|
return failed("报名信息有误,请核查");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- BigDecimal amount = registerPayDto.getAmount();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
|
|
|
BigDecimal orderAmount = new BigDecimal("0");
|
|
BigDecimal orderAmount = new BigDecimal("0");
|
|
|
|
|
|
|
|
//获取课程价格
|
|
//获取课程价格
|
|
|
MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
|
|
MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
|
|
|
- orderAmount.add(musicOneSubjectClassPlan.getFee());
|
|
|
|
|
|
|
+ BigDecimal courseFee = musicOneSubjectClassPlan.getFee();
|
|
|
|
|
+ orderAmount = orderAmount.add(courseFee);
|
|
|
|
|
|
|
|
|
|
|
|
|
//乐器及打包辅件
|
|
//乐器及打包辅件
|
|
|
- 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());//团购减免课程费用
|
|
|
|
|
|
|
+ List<MusicGroupSubjectGoodsGroup> goodsGroups = null;
|
|
|
|
|
+ if (registerPayDto.getGoodsGroupIds() != null && !registerPayDto.getGoodsGroupIds().equals("")) {
|
|
|
|
|
+ goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
|
|
|
|
|
+ for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
|
|
|
|
|
+ orderAmount = orderAmount.add(goodsGroup.getPrice());
|
|
|
|
|
+ //团购乐器减免课程费用
|
|
|
|
|
+ if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && goodsGroup.getRemissionCourseFee() != null && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
|
|
|
|
|
+ orderAmount = orderAmount.subtract(goodsGroup.getRemissionCourseFee());
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//单独辅件
|
|
//单独辅件
|
|
|
- if (registerPayDto.getGoodsIds() != null) {
|
|
|
|
|
- List<Goods> goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
|
|
|
|
|
- goodsList.forEach(goods -> {
|
|
|
|
|
- orderAmount.add(goods.getGroupPurchasePrice());
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ List<Goods> goodsList = null;
|
|
|
|
|
+ if (registerPayDto.getGoodsIds() != null && !registerPayDto.getGoodsIds().equals("")) {
|
|
|
|
|
+ goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
|
|
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
|
|
+ orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //单独教谱
|
|
|
|
|
+ List<Goods> otherGoodsList = null;
|
|
|
|
|
+ if (registerPayDto.getOtherGoodsIds() != null && !registerPayDto.getOtherGoodsIds().equals("")) {
|
|
|
|
|
+ otherGoodsList = goodsService.findGoodsByIds(registerPayDto.getOtherGoodsIds());
|
|
|
|
|
+ for (Goods goods : otherGoodsList) {
|
|
|
|
|
+ orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (amount.compareTo(orderAmount) != 0) {
|
|
if (amount.compareTo(orderAmount) != 0) {
|
|
|
return failed("商品价格不符");
|
|
return failed("商品价格不符");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
IdWorker idWorker = new IdWorker(0, 0);
|
|
IdWorker idWorker = new IdWorker(0, 0);
|
|
|
String orderNo = idWorker.nextId();
|
|
String orderNo = idWorker.nextId();
|
|
|
|
|
|
|
|
- Map payMap = payService.getPayMap(orderAmount,orderNo,"https://pay.dayaedu.com/yqpay/notify","http://dev.dayaedu.com","测试订单","测试订单");
|
|
|
|
|
|
|
+ Map payMap = payService.getPayMap(orderAmount, orderNo, "https://pay.dayaedu.com/yqpay/notify", "http://dev.dayaedu.com", "测试订单", "测试订单");
|
|
|
|
|
+
|
|
|
|
|
+ studentRegistrationService.addOrder(userId, amount, orderNo, "双乾", courseFee, goodsGroups, goodsList, otherGoodsList);
|
|
|
|
|
|
|
|
return succeed(payMap);
|
|
return succeed(payMap);
|
|
|
}
|
|
}
|
|
@@ -150,8 +154,17 @@ public class MusicGroupController extends BaseController {
|
|
|
@GetMapping("/test")
|
|
@GetMapping("/test")
|
|
|
public Object test() throws Exception {
|
|
public Object test() throws Exception {
|
|
|
|
|
|
|
|
|
|
+ IdWorker idWorker = new IdWorker(0, 0);
|
|
|
|
|
+ String orderNo = idWorker.nextId();
|
|
|
BigDecimal amount = new BigDecimal("200");
|
|
BigDecimal amount = new BigDecimal("200");
|
|
|
- Map map = payService.getPayMap(amount,"201910113456789386903","https://pay.dayaedu.com/notify","https://baodiu.com","测试订单","测试订单");
|
|
|
|
|
|
|
+ Map map = payService.getPayMap(amount, orderNo, "https://pay.dayaedu.com/notify", "https://baodiu.com", "测试订单", "测试订单");
|
|
|
return succeed(map);
|
|
return succeed(map);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "订单状态查询")
|
|
|
|
|
+ @GetMapping("/getOrderStatus")
|
|
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "orderNo", value = "订单号", required = true, dataType = "String")})
|
|
|
|
|
+ public HttpResponseResult getOrderStatus(String orderNo) {
|
|
|
|
|
+ return succeed(orderNo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|