|
|
@@ -12,6 +12,8 @@ import com.cyksj.mapper.GoodsDonSkuMapper;
|
|
|
import com.cyksj.mapper.OrderDonMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponUserMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.DistributeGeneralSkuRateMapper;
|
|
|
+import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
|
+import com.cyksj.mapper.manage.distribute.UserPlatDistributeRateMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.UserPlatSkuDistributeRateMapper;
|
|
|
import com.cyksj.model.dto.UserWhoami;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
@@ -39,7 +41,6 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -79,10 +80,14 @@ public class UserController {
|
|
|
|
|
|
private final UserPlatSkuDistributeRateMapper userPlatSkuDistributeRateMapper;
|
|
|
|
|
|
+ private final UserPlatDistributeRateMapper userPlatDistributeRateMapper;
|
|
|
+
|
|
|
private final DistributeGeneralSkuRateMapper distributeGeneralSkuRateMapper;
|
|
|
|
|
|
private final GoodsDonSkuMapper skuMapper;
|
|
|
|
|
|
+ private final UserDistributeMapper userDistributeMapper;
|
|
|
+
|
|
|
@GetMapping(value = "/wx/whoami")
|
|
|
public Result<UserWhoami> whoami() {
|
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
@@ -442,34 +447,72 @@ public class UserController {
|
|
|
@GetMapping("/get/ds/poster/goods")
|
|
|
public Result<List<DistributePosterGoodsFrontView>> getPosterGoods() {
|
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
- List<DistributePosterGoodsFrontView> searchAll = beanSearcher.searchAll(DistributePosterGoodsFrontView.class, MapUtils
|
|
|
- .flatBuilder(request.getParameterMap())
|
|
|
- .put("uid", String.format(" and ud.user_id = %s", userId))
|
|
|
- .build());
|
|
|
+ UserDistribute userDistribute = userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class)
|
|
|
+ .eq(UserDistribute::getUserId, userId)
|
|
|
+ .eq(UserDistribute::getDeleted, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
+ List<DistributePosterGoodsFrontView> searchAll = beanSearcher.searchAll(DistributePosterGoodsFrontView.class, builder.build());
|
|
|
searchAll.forEach(e -> {
|
|
|
+ if (userDistribute != null) {
|
|
|
+ UserPlatDistributeRate userPlatDistributeRate = userPlatDistributeRateMapper.selectOne(Wrappers.lambdaQuery(UserPlatDistributeRate.class)
|
|
|
+ .eq(UserPlatDistributeRate::getDistributeId, userDistribute.getId())
|
|
|
+ .eq(UserPlatDistributeRate::getGoodsId, e.getGoodsId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (userPlatDistributeRate != null) {
|
|
|
+ e.setRate(userPlatDistributeRate.getRate());
|
|
|
+ }
|
|
|
+ }
|
|
|
if (e.getIsSkuRate()) {
|
|
|
- BigDecimal price = e.getPrice();
|
|
|
GoodsDonSku sku = skuMapper.selectOne(Wrappers.lambdaQuery(GoodsDonSku.class)
|
|
|
.eq(GoodsDonSku::getGoodsId, e.getGoodsId())
|
|
|
- .eq(GoodsDonSku::getPrice, price)
|
|
|
+ .eq(GoodsDonSku::getStatus, 1)
|
|
|
+ .orderByAsc(GoodsDonSku::getPrice)
|
|
|
.last("limit 1"));
|
|
|
- if (sku != null) {
|
|
|
- if (e.getDistributeId() != null) {
|
|
|
+ //先获取价格最低的规格对应的 比例
|
|
|
+ //渠道
|
|
|
+ if (userDistribute != null) {
|
|
|
+ UserPlatSkuDistributeRate minPriceSkuRate = userPlatSkuDistributeRateMapper.selectOne(Wrappers.lambdaQuery(UserPlatSkuDistributeRate.class)
|
|
|
+ .eq(UserPlatSkuDistributeRate::getDistributeId, userDistribute.getId())
|
|
|
+ .eq(UserPlatSkuDistributeRate::getGoodsId, e.getGoodsId())
|
|
|
+ .eq(UserPlatSkuDistributeRate::getSkuId, sku.getId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (minPriceSkuRate != null && minPriceSkuRate.getRate() != 0) {
|
|
|
+ e.setRate(minPriceSkuRate.getRate());
|
|
|
+ } else {
|
|
|
UserPlatSkuDistributeRate userPlatSkuDistributeRate = userPlatSkuDistributeRateMapper.selectOne(Wrappers.lambdaQuery(UserPlatSkuDistributeRate.class)
|
|
|
- .eq(UserPlatSkuDistributeRate::getDistributeId, e.getDistributeId())
|
|
|
+ .eq(UserPlatSkuDistributeRate::getDistributeId, userDistribute.getId())
|
|
|
.eq(UserPlatSkuDistributeRate::getGoodsId, e.getGoodsId())
|
|
|
- .eq(UserPlatSkuDistributeRate::getSkuId, sku.getId())
|
|
|
+ .ne(UserPlatSkuDistributeRate::getRate, 0)
|
|
|
+ //上架
|
|
|
+ .apply("exists (select 1 from goods_don_sku sku where sku.id = sku_id and sku.status is true limit 1)")
|
|
|
+ .orderByAsc(UserPlatSkuDistributeRate::getRate)
|
|
|
.last("limit 1"));
|
|
|
if (userPlatSkuDistributeRate != null) {
|
|
|
e.setRate(userPlatSkuDistributeRate.getRate());
|
|
|
+ sku = skuMapper.selectById(userPlatSkuDistributeRate.getSkuId());
|
|
|
+ e.setPrice(sku.getPrice());
|
|
|
}
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //普通
|
|
|
+ DistributeGeneralSkuRate minPriceRate = distributeGeneralSkuRateMapper.selectOne(Wrappers.lambdaQuery(DistributeGeneralSkuRate.class)
|
|
|
+ .eq(DistributeGeneralSkuRate::getGoodsId, e.getGoodsId())
|
|
|
+ .eq(DistributeGeneralSkuRate::getSkuId, sku.getId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (minPriceRate != null && minPriceRate.getRate() > 0) {
|
|
|
+ e.setRate(minPriceRate.getRate());
|
|
|
} else {
|
|
|
DistributeGeneralSkuRate distributeGeneralSkuRate = distributeGeneralSkuRateMapper.selectOne(Wrappers.lambdaQuery(DistributeGeneralSkuRate.class)
|
|
|
.eq(DistributeGeneralSkuRate::getGoodsId, e.getGoodsId())
|
|
|
- .eq(DistributeGeneralSkuRate::getSkuId, sku.getId())
|
|
|
+ .apply("exists (select 1 from goods_don_sku sku where sku.id = sku_id and sku.status is true limit 1)")
|
|
|
+ .ne(DistributeGeneralSkuRate::getRate, 0)
|
|
|
+ .orderByAsc(DistributeGeneralSkuRate::getRate)
|
|
|
.last("limit 1"));
|
|
|
if (distributeGeneralSkuRate != null) {
|
|
|
e.setRate(distributeGeneralSkuRate.getRate());
|
|
|
+ sku = skuMapper.selectById(distributeGeneralSkuRate.getSkuId());
|
|
|
+ e.setPrice(sku.getPrice());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -478,4 +521,14 @@ public class UserController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(searchAll);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 海报详情
|
|
|
+ */
|
|
|
+ @GetMapping("/get/poster/{goodsId}")
|
|
|
+ public Result<DistributePosterGoodsFrontView> getPosterDetail(@PathVariable Long goodsId) {
|
|
|
+ DistributePosterGoodsFrontView distributePosterGoodsView = beanSearcher.searchFirst(DistributePosterGoodsFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .field(DistributePosterGoodsFrontView::getGoodsId, goodsId)
|
|
|
+ .build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(distributePosterGoodsView);
|
|
|
+ }
|
|
|
}
|