|
@@ -7,10 +7,14 @@ import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
|
|
+import com.cyksj.dto.UserSharedDto;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.ClaudeCodeUserMapper;
|
|
import com.cyksj.mapper.ClaudeCodeUserMapper;
|
|
|
import com.cyksj.mapper.GroupsMapper;
|
|
import com.cyksj.mapper.GroupsMapper;
|
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
|
|
+import com.cyksj.mapper.manage.coupon.CouponDistributePopularizeMapper;
|
|
|
|
|
+import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
|
|
+import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
|
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
|
|
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
|
|
@@ -74,6 +78,13 @@ public class ClaudeCodeController {
|
|
|
private final GroupsMapper groupsMapper;
|
|
private final GroupsMapper groupsMapper;
|
|
|
|
|
|
|
|
private final UserService userService;
|
|
private final UserService userService;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserDistributeMapper userDistributeMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final CouponDistributePopularizeMapper couponDistributePopularizeMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final CouponMapper couponMapper;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 用户创建API KEY
|
|
* 用户创建API KEY
|
|
|
*/
|
|
*/
|
|
@@ -190,7 +201,7 @@ public class ClaudeCodeController {
|
|
|
* claude code可选套餐
|
|
* claude code可选套餐
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/get/packages")
|
|
@GetMapping("/get/packages")
|
|
|
- public Result<ClaudeCodePackageView> getClaudeCodePackages() {
|
|
|
|
|
|
|
+ public Result<ClaudeCodePackageView> getClaudeCodePackages(String dsCode) {
|
|
|
Long userId = StpUserUtil.getUserIdAfterLogin();
|
|
Long userId = StpUserUtil.getUserIdAfterLogin();
|
|
|
ClaudeCodePackageView claudeCodePackageView = new ClaudeCodePackageView();
|
|
ClaudeCodePackageView claudeCodePackageView = new ClaudeCodePackageView();
|
|
|
if (userId != null) {
|
|
if (userId != null) {
|
|
@@ -226,6 +237,31 @@ public class ClaudeCodeController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
List<GoodsDonSkuView> goodsDonSkuViews = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getGoodsId, Constant.CLAUDE_CODE_GOODS_ID).field(GoodsDonSkuView::getUserOwns).op(Operator.IsNull).build());
|
|
List<GoodsDonSkuView> goodsDonSkuViews = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getGoodsId, Constant.CLAUDE_CODE_GOODS_ID).field(GoodsDonSkuView::getUserOwns).op(Operator.IsNull).build());
|
|
|
|
|
+ //渠道推广
|
|
|
|
|
+ if (dsCode != null) {
|
|
|
|
|
+ UserSharedDto popularizeDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
|
|
|
+ if (popularizeDto != null) {
|
|
|
|
|
+ UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class).eq(UserDistribute::getUserId, popularizeDto.getSharedId()).eq(UserDistribute::getDeleted, Boolean.TRUE).last("limit 1"));
|
|
|
|
|
+ //渠道推广
|
|
|
|
|
+ if (userDistribute != null) {
|
|
|
|
|
+ Integer selectCount = couponDistributePopularizeMapper.selectCount(Wrappers.lambdaQuery(CouponDistributePopularize.class).eq(CouponDistributePopularize::getDistributeId, userDistribute.getId()).eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID));
|
|
|
|
|
+ //已配置
|
|
|
|
|
+ if (selectCount > 0) {
|
|
|
|
|
+ Coupon coupon = couponMapper.selectById(Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID);
|
|
|
|
|
+ if (coupon != null) {
|
|
|
|
|
+ goodsDonSkuViews.forEach(sku -> {
|
|
|
|
|
+ if (coupon.getType() == Coupon.Type.discount) {
|
|
|
|
|
+ sku.setDiscount(coupon.getDiscount());
|
|
|
|
|
+ sku.setDiscountPrice(sku.getMoney().multiply(coupon.getDiscount()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sku.setReduceMoney(coupon.getReduceMoney());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
claudeCodePackageView.setSkus(goodsDonSkuViews);
|
|
claudeCodePackageView.setSkus(goodsDonSkuViews);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(claudeCodePackageView);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(claudeCodePackageView);
|
|
|
}
|
|
}
|