|
@@ -0,0 +1,98 @@
|
|
|
|
|
+package com.cyksj.web.controller.wholesale;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.cyksj.dto.Result;
|
|
|
|
|
+import com.cyksj.enums.GatewayResponse;
|
|
|
|
|
+import com.cyksj.mapper.GoodsWholesaleOrderDonMapper;
|
|
|
|
|
+import com.cyksj.mapper.GoodsWholesaleUserDepositMapper;
|
|
|
|
|
+import com.cyksj.model.entity.GoodsWholesaleOrderDon;
|
|
|
|
|
+import com.cyksj.model.entity.GoodsWholesaleUserDeposit;
|
|
|
|
|
+import com.cyksj.model.request.GoodsWholesaleOrderPayReq;
|
|
|
|
|
+import com.cyksj.model.views.GoodsWholesaleFrontView;
|
|
|
|
|
+import com.cyksj.redis.RedisService;
|
|
|
|
|
+import com.cyksj.service.order.GoodsWholesalePayService;
|
|
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
|
|
+import com.cyksj.web.util.StpUserUtil;
|
|
|
|
|
+import com.ejlchina.searcher.BeanSearcher;
|
|
|
|
|
+import com.ejlchina.searcher.util.MapUtils;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 项目名: yhlxj
|
|
|
|
|
+ * 文件名: GoodsWholesaleWebControlelr
|
|
|
|
|
+ * 创建者: JavaZou
|
|
|
|
|
+ * 创建时间:2024/8/26 17:41
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/applet/wholesale")
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+public class GoodsWholesaleWebController {
|
|
|
|
|
+ private final BeanSearcher beanSearcher;
|
|
|
|
|
+
|
|
|
|
|
+ private final HttpServletRequest request;
|
|
|
|
|
+
|
|
|
|
|
+ private final RedisService redisService;
|
|
|
|
|
+
|
|
|
|
|
+ private final GoodsWholesaleOrderDonMapper orderDonMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
|
|
+
|
|
|
|
|
+ private final GoodsWholesaleUserDepositMapper goodsWholesaleUserDepositMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final GoodsWholesalePayService goodsWholesalePayService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 平台批发列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
|
+ public Result<List<GoodsWholesaleFrontView>> goodsWholesaleList() {
|
|
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ String key = RedisService.key.GOODS_WHOLESALE_KEY.getName();
|
|
|
|
|
+ List<GoodsWholesaleFrontView> list = (List<GoodsWholesaleFrontView>) redisService.get(key);
|
|
|
|
|
+
|
|
|
|
|
+ if (list == null) {
|
|
|
|
|
+ list = beanSearcher.searchAll(GoodsWholesaleFrontView.class, MapUtils.builder().build());
|
|
|
|
|
+ redisService.setNx(key, list, RedisService.key.GOODS_WHOLESALE_KEY.getTimeout());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ list.forEach(data->{
|
|
|
|
|
+ data.setTotal(orderDonMapper.getUserWholesaleNumByUserIds(userIdList));
|
|
|
|
|
+ });
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/get/deposit/detail")
|
|
|
|
|
+ public Result<String> getUserDepositDetail() {
|
|
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ GoodsWholesaleUserDeposit goodsWholesaleUserDeposit = goodsWholesaleUserDepositMapper.selectOne(Wrappers.lambdaQuery(GoodsWholesaleUserDeposit.class)
|
|
|
|
|
+ .in(GoodsWholesaleUserDeposit::getUserId, userIdList)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (goodsWholesaleUserDeposit == null) {
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(GoodsWholesaleUserDeposit.Status.noPayment.name());
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(goodsWholesaleUserDeposit.getStatus().name());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 支付押金
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 下单批发
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/post/submit")
|
|
|
|
|
+ public Result<GoodsWholesaleOrderDon> submit(@RequestBody @Validated GoodsWholesaleOrderPayReq payReq) {
|
|
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ payReq.setUserId(userId);
|
|
|
|
|
+ GoodsWholesaleOrderDon orderDon = goodsWholesalePayService.unifiedPay(payReq);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|