Bladeren bron

Merge remote-tracking branch 'origin/feature/0124' into feature/0124

Eric 1 jaar geleden
bovenliggende
commit
5fdb022837
15 gewijzigde bestanden met toevoegingen van 238 en 33 verwijderingen
  1. 3 2
      cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/TenantGroupAlbumController.java
  2. 1 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/student/vo/UserPaymentOrderVo.java
  3. 3 2
      cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/TenantGroupAlbumController.java
  4. 1 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/PeriodEnum.java
  5. 4 4
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantGroupAlbumService.java
  6. 7 5
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PaymentDivMemberRecordServiceImpl.java
  7. 24 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java
  8. 74 9
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumServiceImpl.java
  9. 3 4
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantGroupAlbumServiceImpl.java
  10. 4 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumPurchaseWrapper.java
  11. 12 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumWrapper.java
  12. 87 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantGroupAlbumWrapper.java
  13. 4 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/UserPaymentOrderWrapper.java
  14. 1 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumPurchaseMapper.xml
  15. 10 5
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantGroupAlbumMapper.xml

+ 3 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/TenantGroupAlbumController.java

@@ -15,6 +15,7 @@ import org.springframework.http.HttpStatus;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
@@ -34,13 +35,13 @@ public class TenantGroupAlbumController {
 
 	@ApiOperation(value = "学生可购买机构专辑信息")
 	@GetMapping("/buyAlbumInfo")
-	public HttpResponseResult<List<TenantGroupAlbumWrapper.BuyTenantAlbum>> buyAlbumInfo() {
+	public HttpResponseResult<List<TenantGroupAlbumWrapper.BuyTenantAlbum>> buyAlbumInfo(@RequestParam(required = false) Long tenantGroupAlbumId) {
 
         SysUser user = sysUserFeignService.queryUserInfo();
         if (user == null || null == user.getId()) {
             return HttpResponseResult.failed(HttpStatus.FORBIDDEN, "请登录");
         }
     
-		return HttpResponseResult.succeed(tenantGroupAlbumService.buyAlbumInfo(user.getId(), ClientEnum.STUDENT));
+		return HttpResponseResult.succeed(tenantGroupAlbumService.buyAlbumInfo(tenantGroupAlbumId,user.getId(), ClientEnum.STUDENT));
 	}
 }

+ 1 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/student/vo/UserPaymentOrderVo.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.student.vo;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.yonge.cooleshow.biz.dal.enums.OrderTypeEnum;
 import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper;
 import io.swagger.annotations.ApiModel;

+ 3 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/TenantGroupAlbumController.java

@@ -14,6 +14,7 @@ import org.springframework.http.HttpStatus;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
@@ -33,13 +34,13 @@ public class TenantGroupAlbumController {
 
 	@ApiOperation(value = "机构可购买机构专辑信息")
 	@GetMapping("/buyAlbumInfo")
-	public HttpResponseResult<List<TenantGroupAlbumWrapper.BuyTenantAlbum>> buyAlbumInfo() {
+	public HttpResponseResult<List<TenantGroupAlbumWrapper.BuyTenantAlbum>> buyAlbumInfo(@RequestParam(required = false) Long tenantGroupAlbumId) {
 
         SysUser user = sysUserFeignService.queryUserInfo();
         if (user == null || null == user.getId()) {
             return HttpResponseResult.failed(HttpStatus.FORBIDDEN, "请登录");
         }
     
-		return HttpResponseResult.succeed(tenantGroupAlbumService.buyAlbumInfo(user.getId(), ClientEnum.TENANT));
+		return HttpResponseResult.succeed(tenantGroupAlbumService.buyAlbumInfo(tenantGroupAlbumId, user.getId(), ClientEnum.TENANT));
 	}
 }

+ 1 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/PeriodEnum.java

@@ -7,6 +7,7 @@ import com.yonge.toolset.base.enums.BaseEnum;
  * 周期
  */
 public enum PeriodEnum implements BaseEnum<String, PeriodEnum> {
+    // DAY 日 MONTH 月 QUARTERLY 季度 YEAR_HALF 半年 YEAR 年
 	DAY("日"),
 	MONTH("月"),
 	QUARTERLY("季度"),

+ 4 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantGroupAlbumService.java

@@ -2,7 +2,6 @@ package com.yonge.cooleshow.biz.dal.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.microsvc.toolkit.common.response.ParamResponse;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupAlbumWrapper;
 import com.yonge.cooleshow.biz.dal.entity.TenantGroupAlbum;
@@ -47,8 +46,9 @@ public interface TenantGroupAlbumService extends IService<TenantGroupAlbum>  {
     /**
      * 可购买机构信息
      *
-     * @param userId 用户ID
-     * @param clientType 客户端类型
+     * @param tenantGroupAlbumId
+     * @param userId             用户ID
+     * @param clientType         客户端类型
      */
-    List<TenantGroupAlbumWrapper.BuyTenantAlbum> buyAlbumInfo(Long userId, ClientEnum clientType);
+    List<TenantGroupAlbumWrapper.BuyTenantAlbum> buyAlbumInfo(Long tenantGroupAlbumId, Long userId, ClientEnum clientType);
 }

+ 7 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/PaymentDivMemberRecordServiceImpl.java

@@ -244,7 +244,6 @@ public class PaymentDivMemberRecordServiceImpl extends ServiceImpl<PaymentDivMem
         // 老师收入
         Map<Long, BigDecimal> bizMap = new HashMap<>();
 
-        tenantdivMap.merge(-1L, userPaymentOrder.getActualPrice(), BigDecimal::add);
         // 计算商品分账数据
         if (userPaymentOrder.getOrderClient().equals(ClientEnum.STUDENT)) {
 
@@ -253,12 +252,15 @@ public class PaymentDivMemberRecordServiceImpl extends ServiceImpl<PaymentDivMem
                     .parseObject(userPaymentOrder.getBizContent(), TenantAlbumWrapper.TenantAlbumContent.class);
 
 
-            BigDecimal tenantAmount = tenantAlbumContent.getSalePrice().subtract(tenantAlbumContent.getOriginalPrice())
-                    .multiply(BigDecimal.valueOf(tenantAlbumContent.getBuyMultiple())).setScale(2, RoundingMode.HALF_UP);
+//            BigDecimal tenantAmount = tenantAlbumContent.getSalePrice().subtract(tenantAlbumContent.getOriginalPrice())
+//                    .multiply(BigDecimal.valueOf(tenantAlbumContent.getBuyMultiple())).setScale(2, RoundingMode.HALF_UP);
+
+            tenantdivMap.merge(tenantAlbumContent.getTenantId(), userPaymentOrder.getActualPrice(), BigDecimal::add);
+//            tenantdivMap.merge(-1L, tenantAmount, BigDecimal::subtract);
 
-            tenantdivMap.merge(tenantAlbumContent.getTenantId(), tenantAmount, BigDecimal::add);
-            tenantdivMap.merge(-1L, tenantAmount, BigDecimal::subtract);
+        } else {
 
+            tenantdivMap.merge(-1L, userPaymentOrder.getActualPrice(), BigDecimal::add);
         }
 
         // 计算老师分润数据  平台的真实收益

+ 24 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java

@@ -616,6 +616,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             userTenantAlbumRecord.setSubOrderNo(userOrderDetailVo.getSubOrderNo());
             userTenantAlbumRecord.setCreateBy(studentId);
             userTenantAlbumRecord.setTimes(tenantAlbumContent.getBuyCycle());
+            userTenantAlbumRecord.setType(tenantAlbumContent.getPurchaseType());
         } else if (purchase != null) {
 
             userTenantAlbumRecord.setTenantId(purchase.getTenantId());
@@ -627,6 +628,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             userTenantAlbumRecord.setSubOrderNo(purchase.getId().toString());
             userTenantAlbumRecord.setCreateBy(studentId);
             userTenantAlbumRecord.setTimes(purchase.getPurchaseCycle());
+            userTenantAlbumRecord.setType(purchase.getPurchaseType());
         }
 
         List<UserTenantAlbumRecord> userTenantAlbumRecords = userTenantAlbumRecordMapper
@@ -641,7 +643,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         userTenantAlbumRecord.setCreateBy(studentId);
 
 
-        userTenantAlbumRecord.setType("MONTH");
+//        userTenantAlbumRecord.setType("MONTH");
 
         Calendar instance = Calendar.getInstance();
         if (userTenantAlbumRecords.isEmpty()) {
@@ -658,7 +660,27 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
             }
         }
         userTenantAlbumRecord.setStartTime(instance.getTime());
-        instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
+        //DAY 日 MONTH 月 QUARTERLY 季度 YEAR_HALF 半年 YEAR 年
+        switch (userTenantAlbumRecord.getType()) {
+            case "DAY":
+                instance.add(Calendar.DAY_OF_MONTH, userTenantAlbumRecord.getTimes());
+                break;
+            case "MONTH":
+                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
+                break;
+            case "QUARTERLY":
+                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes() * 3);
+                break;
+            case "YEAR_HALF":
+                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes() * 6);
+                break;
+            case "YEAR":
+                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes() * 12);
+                break;
+            default:
+                instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
+                break;
+        }
 
         instance.set(Calendar.HOUR_OF_DAY, 23);
         instance.set(Calendar.MINUTE, 59);

+ 74 - 9
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumServiceImpl.java

@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.beust.jcommander.internal.Lists;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.dao.UserOrderDao;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.*;
 import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
@@ -88,6 +90,13 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
 
     @Autowired
     private UserTenantAlbumRecordService userTenantAlbumRecordService;
+
+    @Autowired
+    private TenantGroupAlbumService tenantGroupAlbumService;
+
+    @Autowired
+    private UserOrderDao userOrderDao;
+
     /**
      * 查询详情
      *
@@ -202,9 +211,9 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
             log.error("订单创建前检测,专辑不存在,bizId={}", orderGoodsInfo.getBizId());
             throw new BizException("订单商品信息为空");
         }
-        tenantAlbumContent.setBuyCycle(tenantAlbum.getPurchaseCycle());
-        tenantAlbumContent.setSalePrice(tenantAlbum.getSalePrice());
-        tenantAlbumContent.setOriginalPrice(tenantAlbum.getOriginalPrice());
+//        tenantAlbumContent.setBuyCycle(tenantAlbum.getPurchaseCycle());
+//        tenantAlbumContent.setSalePrice(tenantAlbum.getSalePrice());
+//        tenantAlbumContent.setOriginalPrice(tenantAlbum.getOriginalPrice());
 
         // 查询专辑所在机构
         List<TenantAlbumRef> refList =
@@ -223,7 +232,8 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
 
         // 设置金额入账去向
         UserPaymentOrderWrapper.AccountTenantTo accountTenantTo = teacherService.teacherSettlementFrom(null, orderGoodsInfo.getRecomUserId());
-        BigDecimal price = BigDecimal.ZERO;
+        BigDecimal originalPrice = BigDecimal.ZERO;
+        BigDecimal actualPrice = BigDecimal.ZERO;
         // 学生购买机构专辑
         switch (orderGoodsInfo.getPaymentClient()) {
             case STUDENT: {
@@ -238,10 +248,36 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
                     log.error("订单创建前检测,学生不在当前机构下,userId={},tenantId={}", orderGoodsInfo.getUserId(), student.getTenantId());
                     throw new BizException("用户不在当前机构");
                 }
-                price = tenantAlbum.getSalePrice();
+                if (orderGoodsInfo.getTenantGroupAlbumId() == null) {
+                    log.error("订单创建前检测,学生购买机构专辑,机构小组专辑ID为空,userId={}", orderGoodsInfo.getUserId());
+                    throw new BizException("机构小组专辑ID为空");
+                }
+                // 判断机构小组专辑ID是否能购买,专辑ID和当前机构专辑ID是否对应
+                TenantGroupAlbum tenantGroupAlbum = tenantGroupAlbumService.getById(orderGoodsInfo.getTenantGroupAlbumId());
+                if (tenantGroupAlbum == null) {
+                    log.error("订单创建前检测,学生购买机构专辑,机构小组专辑不存在,userId={},tenantGroupAlbumId={}", orderGoodsInfo.getUserId(), orderGoodsInfo.getTenantGroupAlbumId());
+                    throw new BizException("小组专辑不存在");
+                }
+                if (!tenantGroupAlbum.getTenantAlbumId().equals(orderGoodsInfo.getBizId())) {
+                    log.error("订单创建前检测,学生购买机构专辑,机构小组专辑ID和当前机构专辑ID不对应,userId={},tenantGroupAlbumId={},bizId={}", orderGoodsInfo.getUserId(), orderGoodsInfo.getTenantGroupAlbumId(), orderGoodsInfo.getBizId());
+                    throw new BizException("小组专辑和当前购买专辑不对应");
+                }
+                // 判断购买次数
+                if (tenantGroupAlbum.getBuyTimesFlag()) {
+                    List<Long> studentTenantAlbumNum = userOrderDao.getStudentTenantAlbumNum(student.getUserId(), Lists.newArrayList(tenantGroupAlbum.getId()));
+                    if (CollectionUtils.isNotEmpty(studentTenantAlbumNum) && studentTenantAlbumNum.size() >tenantGroupAlbum.getBuyTimes()) {
+                        log.error("订单创建前检测,学生购买机构专辑,机构小组专辑购买次数超过限制,userId={},tenantGroupAlbumId={},buyTimes={}", orderGoodsInfo.getUserId(), orderGoodsInfo.getTenantGroupAlbumId(), tenantGroupAlbum.getBuyTimes());
+                        throw new BizException("购买次数超过限制");
+                    }
+                }
+
+                originalPrice = tenantGroupAlbum.getOriginalPrice();
+                actualPrice = tenantGroupAlbum.getActualPrice();
                 userOrderDetail.setMerchId(tenantInfo.getId());
+                userOrderDetail.setTenantGroupAlbumId(tenantGroupAlbum.getId());
                 tenantAlbumContent.setBuyNumber(1);
-                tenantAlbumContent.setBuyCycle(tenantAlbumContent.getBuyCycle()*tenantAlbumContent.getBuyMultiple());
+                tenantAlbumContent.setBuyCycle(tenantGroupAlbum.getPurchaseNum());
+                tenantAlbumContent.setPurchaseType(tenantGroupAlbum.getPurchasePeriod());
                 tenantAlbumContent.setTenantId(tenantInfo.getId());
                 accountTenantTo.setIncomeTenant(tenantInfo.getId());
                 break;
@@ -258,7 +294,34 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
                     log.error("订单创建前检测,专辑不在机构下,userId={},tenantId={}", orderGoodsInfo.getUserId(), tenantStaff.getTenantId());
                     throw new BizException("用户不在当前机构");
                 }
-                price = tenantAlbum.getOriginalPrice();
+                // 根据周期判断能不能购买当前周期的专辑
+                if (StringUtil.isEmpty(tenantAlbum.getPurchaseTypes())) {
+                    log.error("订单创建前检测,机构购买机构专辑,专辑周期为空,userId={},bizId={}", orderGoodsInfo.getUserId(), orderGoodsInfo.getBizId());
+                    throw new BizException("专辑不支持当前周期");
+                }
+                List<String> purchaseTypes = Arrays.asList(tenantAlbum.getPurchaseTypes().split(","));
+                if (!purchaseTypes.contains(tenantAlbumContent.getPurchaseType())) {
+                    log.error("订单创建前检测,机构购买机构专辑,专辑周期不支持,userId={},bizId={},purchaseType={}", orderGoodsInfo.getUserId(),
+                        orderGoodsInfo.getBizId(), tenantAlbumContent.getPurchaseType());
+                    throw new BizException("专辑不支持当前周期");
+                }
+                List<TenantAlbumWrapper.TenantAlbumPurchaseJson> tenantAlbumPurchaseJsons = JSON
+                    .parseArray(tenantAlbum.getPurchaseJson(), TenantAlbumWrapper.TenantAlbumPurchaseJson.class);
+                if (CollectionUtils.isEmpty(tenantAlbumPurchaseJsons)) {
+                    log.error("订单创建前检测,机构购买机构专辑,专辑周期不支持,userId={},bizId={},purchaseType={}", orderGoodsInfo.getUserId(),
+                        orderGoodsInfo.getBizId(), tenantAlbumContent.getPurchaseType());
+                    throw new BizException("专辑不支持当前周期");
+                }
+                Optional<TenantAlbumWrapper.TenantAlbumPurchaseJson> first = tenantAlbumPurchaseJsons.stream().filter(o -> o.getPurchaseType().equals(tenantAlbumContent.getPurchaseType())).findFirst();
+                if (!first.isPresent()) {
+                    log.error("订单创建前检测,机构购买机构专辑,专辑周期不支持,userId={},bizId={},purchaseType={}", orderGoodsInfo.getUserId(),
+                        orderGoodsInfo.getBizId(), tenantAlbumContent.getPurchaseType());
+                    throw new BizException("专辑不支持当前周期");
+                }
+                TenantAlbumWrapper.TenantAlbumPurchaseJson tenantAlbumPurchaseJson = first.get();
+
+                originalPrice = tenantAlbumPurchaseJson.getPrice();
+                actualPrice = tenantAlbumPurchaseJson.getPrice();
                 userOrderDetail.setMerchId(0L);
                 tenantAlbumContent.setTenantId(tenantStaff.getTenantId());
                 tenantAlbumContent.setBuyCycle(tenantAlbumContent.getBuyCycle()*tenantAlbumContent.getBuyMultiple());
@@ -272,10 +335,11 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
         userOrderDetail.setBizId(tenantAlbum.getId());
         userOrderDetail.setBizContent(JSON.toJSONString(tenantAlbumContent));
         userOrderDetail.setGoodNum(orderGoodsInfo.getGoodNum());
-        userOrderDetail.setOriginalPrice(price.multiply(new BigDecimal(orderGoodsInfo.getGoodNum()))
+        userOrderDetail.setOriginalPrice(originalPrice.multiply(new BigDecimal(orderGoodsInfo.getGoodNum()))
                 .multiply(new BigDecimal(tenantAlbumContent.getBuyMultiple())));
         userOrderDetail.setCouponAmount(BigDecimal.ZERO);
-        userOrderDetail.setExpectPrice(userOrderDetail.getOriginalPrice());
+        userOrderDetail.setExpectPrice(actualPrice.multiply(new BigDecimal(orderGoodsInfo.getGoodNum()))
+            .multiply(new BigDecimal(tenantAlbumContent.getBuyMultiple())));
         userOrderDetail.setActualPrice(userOrderDetail.getExpectPrice());
         userOrderDetail.setAccountConfig(accountTenantTo.jsonString());
 
@@ -515,6 +579,7 @@ public class TenantAlbumServiceImpl extends ServiceImpl<TenantAlbumMapper, Tenan
         tenantAlbumPurchase.setPurchaseCycle(tenantAlbumContent.getBuyCycle());
         tenantAlbumPurchase.setActiveQuantity(0);
         tenantAlbumPurchase.setOrderNo(orderGoodsInfo.getOrderNo());
+        tenantAlbumPurchase.setPurchaseType(tenantAlbumContent.getPurchaseType());
         tenantAlbumPurchase.setPurchasePrice(orderGoodsInfo.getUserOrderDetail().getActualPrice());
         tenantAlbumPurchase.setPurchaseStatus(OrderStatusEnum.WAIT_PAY.getCode());
         tenantAlbumPurchaseService.save(tenantAlbumPurchase);

+ 3 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantGroupAlbumServiceImpl.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.biz.dal.dao.UserOrderDao;
 import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
-import com.yonge.cooleshow.biz.dal.entity.UserOrder;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.service.StudentService;
 import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
@@ -14,7 +13,6 @@ import com.yonge.toolset.base.exception.BizException;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.beans.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
 import com.yonge.cooleshow.biz.dal.entity.TenantGroupAlbum;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupAlbumWrapper;
@@ -87,11 +85,12 @@ public class TenantGroupAlbumServiceImpl extends ServiceImpl<TenantGroupAlbumMap
     }
 
     @Override
-    public List<TenantGroupAlbumWrapper.BuyTenantAlbum> buyAlbumInfo(Long userId, ClientEnum clientType) {
+    public List<TenantGroupAlbumWrapper.BuyTenantAlbum> buyAlbumInfo(Long tenantGroupAlbumId, Long userId, ClientEnum clientType) {
         // 学生端 查看小组专辑 获取专辑基本信息, 机构端查看机构专辑 获取专辑基本信息
 
         TenantGroupAlbumWrapper.BuyTenantAlbumQuery query = new TenantGroupAlbumWrapper.BuyTenantAlbumQuery();
-        if (clientType == ClientEnum.STUDENT) {
+        query.setTenantGroupAlbumId(tenantGroupAlbumId);
+        if (tenantGroupAlbumId != null) {} else if (clientType == ClientEnum.STUDENT) {
             Student student = studentService.getById(userId);
             if (student.getTenantId() == null || student.getTenantId() <=0 || student.getTenantGroupId() == null) {
                 throw new BizException("学生未加入机构或者小组");

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumPurchaseWrapper.java

@@ -106,6 +106,10 @@ public class TenantAlbumPurchaseWrapper {
         @ApiModelProperty("采购状态")
         private String purchaseStatus;
 
+        @ApiModelProperty("采购周期类型 DAY 日 MONTH 月 QUARTERLY 季度 YEAR_HALF 半年 YEAR 年")
+        private String purchaseType;
+
+
         @ApiModelProperty("更新时间")
         private Date updateTime;
 

+ 12 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumWrapper.java

@@ -227,6 +227,9 @@ public class TenantAlbumWrapper {
         @ApiModelProperty(value = "采购周期", hidden = true)
         private Integer buyCycle;
 
+        @ApiModelProperty(value = "采购周期类型")
+        private String purchaseType;
+
         @ApiModelProperty(value = "采购机构", hidden = true)
         private Long tenantId;
 
@@ -374,5 +377,14 @@ public class TenantAlbumWrapper {
     }
 
 
+    @Data
+    public static class TenantAlbumPurchaseJson {
+
+        @ApiModelProperty("采购周期类型")
+        private String purchaseType;
+
+        @ApiModelProperty("金额")
+        private BigDecimal price;
+    }
 
 }

+ 87 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantGroupAlbumWrapper.java

@@ -177,5 +177,92 @@ public class TenantGroupAlbumWrapper {
         private String tenantAlbumName;
 
     }
+    @Data
+    @ApiModel(" BuyTenantAlbumQuery-可购买机构专辑信息查询")
+    public static class BuyTenantAlbumQuery {
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("小组ID")
+        private Long tenantGroupId;
+
+        @ApiModelProperty("机构小组专辑ID")
+        private Long tenantGroupAlbumId;
+    }
+
+
+
+    @Data
+    @ApiModel(" BuyTenantAlbum-可购买机构专辑信息")
+    public static class BuyTenantAlbum {
+
+        @ApiModelProperty("专辑ID")
+        private Long id;
+
+
+        @ApiModelProperty("专辑名称")
+        private String name;
+
+        @ApiModelProperty("专辑介绍")
+        private String describe;
+
+        @ApiModelProperty("专辑封面")
+        private String coverImg;
+
+        @ApiModelProperty("曲目数")
+        private Integer musicNum;
+
+
+        @ApiModelProperty("曲目声部分类(多个,分隔)")
+        private String subjectTypes;
+
+
+        @ApiModelProperty("采购周期类型")
+        private String purchaseTypes;
+
+
+
+        @ApiModelProperty("采购金额数据")
+        private String purchaseJson;
+
+
+        @ApiModelProperty("机构小组专辑ID ,学生购买需传参")
+        private Long tenantGroupAlbumId;
+
+        @ApiModelProperty("机构小组ID")
+        private Long tenantGroupId;
+
+
+        @ApiModelProperty("采购数量")
+        private Integer purchaseNum;
+
+        @ApiModelProperty("采购周期")
+        private String purchasePeriod;
+
+        @ApiModelProperty("原价")
+        private BigDecimal originalPrice;
+
+        @ApiModelProperty("售价")
+        private BigDecimal actualPrice;
+
+
+        @ApiModelProperty("购买次数限制")
+        private Boolean buyTimesFlag;
+
+        @ApiModelProperty("可购买次数")
+        private Integer buyTimes;
+
+        @ApiModelProperty("已购买次数")
+        private Integer buyedTimes;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantGroupAlbum from(String json) {
+            return JSON.parseObject(json, TenantGroupAlbum.class);
+        }
+    }
 
 }

+ 4 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/UserPaymentOrderWrapper.java

@@ -825,6 +825,10 @@ public class UserPaymentOrderWrapper {
         @ApiModelProperty("优惠券Id")
         private Long couponId;
 
+
+        @ApiModelProperty("学生购买机构专辑时的小组ID")
+        private Long tenantGroupAlbumId;
+
         @ApiModelProperty(value = "活动id", hidden = true)
         private Long activityId;
 

+ 1 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumPurchaseMapper.xml

@@ -16,6 +16,7 @@
         , t.active_quantity_ AS activeQuantity
         , t.purchase_price_ AS purchasePrice
         , t.purchase_status_ AS purchaseStatus
+        , t.purchase_type_ AS purchaseType
         , t.active_status_ AS activeStatus
         , t.update_time_ AS updateTime
         , t.create_time_ AS createTime

+ 10 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantGroupAlbumMapper.xml

@@ -27,7 +27,7 @@
 		SELECT         
         	<include refid="baseColumns" />
         ,tg.name_ tenantGroupName
-        ,tg.name_ tenantGroupName
+        ,ta.name_ tenantAlbumName
 		FROM tenant_group_album t
         LEFT JOIN tenant_group tg ON t.tenant_group_id_ = tg.id_
         LEFT JOIN tenant_album ta ON t.tenant_album_id_ = ta.id_
@@ -57,7 +57,7 @@
         t.subject_types_,
         t.purchase_types_,
         t.purchase_json_
-        <if test="param.tenantGroupId != null">
+        <if test="param.tenantGroupId != null or param.tenantGroupAlbumId != null">
             ,
             t2.id_ as tenantGroupAlbumId,
             t2.tenant_group_id_,
@@ -70,7 +70,7 @@
         </if>
         from tenant_album t
 
-        <if test="param.tenantGroupId != null">
+        <if test="param.tenantGroupId != null or param.tenantGroupAlbumId != null">
             left join tenant_group_album t2 on t2.tenant_album_id_ = t.id_
         </if>
         <if test="param.tenantId != null">
@@ -81,9 +81,14 @@
             <if test="param.tenantId != null">
                 and t1.tenant_id_ = #{param.tenantId}
             </if>
-            <if test="param.tenantGroupId != null">
+            <if test="param.tenantGroupId != null  or param.tenantGroupAlbumId != null">
                 and t2.status_ = 1 and t2.del_flag_ = 0
-                and t2.tenant_group_id_ = #{param.tenantGroupId}
+                <if test="param.tenantGroupId != null">
+                    and t2.tenant_group_id_ = #{param.tenantGroupId}
+                </if>
+                <if test="param.tenantGroupAlbumId != null">
+                    and t2.id_ = #{param.tenantGroupAlbumId}
+                </if>
             </if>
         </where>
     </select>