nickchange
2023-11-09 c036557db88c6297b9a626a892dce35c14ab8ee5
cloud-server-activity/src/main/java/com/dsh/activity/controller/CouponController.java
@@ -16,7 +16,6 @@
import com.dsh.activity.feignclient.account.StudentClient;
import com.dsh.activity.feignclient.account.model.AppUserByNameAndPhoneDTO;
import com.dsh.activity.feignclient.account.model.TCityManager;
import com.dsh.activity.feignclient.account.model.TStoreStaff;
import com.dsh.activity.feignclient.model.CouponExamineListSearch;
import com.dsh.activity.feignclient.model.CouponListOfSearch;
import com.dsh.activity.feignclient.model.TAppUser;
@@ -25,6 +24,7 @@
import com.dsh.activity.feignclient.other.StoreClient;
import com.dsh.activity.feignclient.other.model.CityDataAndProvinceDataVo;
import com.dsh.activity.feignclient.other.model.Store;
import com.dsh.activity.feignclient.other.model.StoreInfoDto;
import com.dsh.activity.feignclient.other.model.TOperatorCity;
import com.dsh.activity.model.CouponListVo;
import com.dsh.activity.model.CouponRecordQuery;
@@ -44,6 +44,7 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -84,6 +85,7 @@
    @Resource
    private StoreClient stoClient;
    @Resource
@@ -173,6 +175,35 @@
        try {
            Coupon coupon = couponService.getById(id);
            return coupon;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    @Autowired
    private UserCouponService userCouponService;
    @ResponseBody
    @PostMapping("/coupon/queryCouponByUid")
    public List<Coupon> queryCouponByUid(@RequestBody Integer uid){
        try {
            LocalDateTime currentTime = LocalDateTime.now();
            LocalDateTime oneMinuteAgo = currentTime.minusSeconds(20);
            List<UserCoupon> list = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", uid).ge("insertTime", oneMinuteAgo));
            List<Integer> ids = new ArrayList<>();
            for (UserCoupon userCoupon : list) {
                ids.add(userCoupon.getCouponId());
            }
            if (ids.size()>0){
            List<Coupon> userId = couponService.list(new QueryWrapper<Coupon>().in("id",ids));
                return userId;
            }
            return null;
        }catch (Exception e){
            e.printStackTrace();
            return null;
@@ -430,11 +461,7 @@
            couponInfo.put("id",coupon.getId());
            couponInfo.put("auditStatus",coupon.getAuditStatus());
            couponInfo.put("publisherType",coupon.getPublisherType());
            if (coupon.getPublisherType() == 1){
                TCityManager byId = citClient.getById(coupon.getCityManagerId());
                couponInfo.put("province",byId.getProvince());
                couponInfo.put("city",byId.getCity());
            }
            couponInfo.put("name",coupon.getName());
            couponInfo.put("type",coupon.getType());
            JSONObject jsonObject = JSON.parseObject(coupon.getContent());
@@ -508,14 +535,16 @@
                    List<CouponStore> list = couStoreService.list(new LambdaQueryWrapper<CouponStore>()
                            .eq(CouponStore::getCouponId,coupon.getId()));
                    if (list.size() > 0){
                        // 获取门店ids
                        List<Integer> collect = list.stream().map(CouponStore::getStoreId).collect(Collectors.toList());
                        List<Store> storeList = stoClient.queryStoreByIds(collect);
                        if (storeList.size() > 0){
                            for (Store store : storeList) {
                                TStoreStaff list1 = stoStaClient.baseInfo(store.getStoreStaffId());
                                StoreInfoDto storeInfo = stoClient.getStoreInfo(store.getStoreStaffId());
                                HashMap<String, Object> stringObjectHashMap = new HashMap<>();
                                stringObjectHashMap.put("procity",store.getProvince()+store.getCity());
                                stringObjectHashMap.put("storeAccount",list1.getName()+"+"+list1.getPhone());
                                stringObjectHashMap.put("storeAccount",storeInfo.getInfo());
                                stringObjectHashMap.put("storeName",store.getName());
                                maps.add(stringObjectHashMap);
                            }