| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.activity.entity.PointsMerchandise; |
| | | import com.dsh.activity.entity.UserPointsMerchandise; |
| | | import com.dsh.activity.feignclient.model.IntegralCommodity; |
| | | import com.dsh.activity.model.request.CommodityRequest; |
| | | import com.dsh.activity.service.PointsMerchandiseService; |
| | | import com.dsh.activity.service.UserPointsMerchandiseService; |
| | | import com.dsh.activity.util.GDMapGeocodingUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | |
| | | |
| | | @Autowired |
| | | private PointsMerchandiseService pmdsService; |
| | | |
| | | @Autowired |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | |
| | | @Autowired |
| | | private UserPointsMerchandiseService upmseService; |
| | | |
| | | |
| | | |
| | |
| | | return commodity; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/pointMerchars/getCommoditys") |
| | | public List<PointsMerchandise> getVicinityGoods(@RequestBody CommodityRequest request){ |
| | | String provinceCode = ""; |
| | | String cityCode = ""; |
| | | try { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat()); |
| | | provinceCode = geocode.get("provinceCode"); |
| | | cityCode = geocode.get("cityCode"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | List<PointsMerchandise> list = pmdsService.list(new QueryWrapper<PointsMerchandise>() |
| | | .eq("state", 1)); |
| | | if (list.size() > 0 ){ |
| | | Iterator<PointsMerchandise> iterator = list.iterator(); |
| | | while (iterator.hasNext()) { |
| | | PointsMerchandise merchandise = iterator.next(); |
| | | if (merchandise.getUseScope() == 2 && (!Objects.equals(merchandise.getCityCode(), cityCode) && !Objects.equals(merchandise.getProvinceCode(), provinceCode))) { |
| | | iterator.remove(); // 移除符合条件的商品 |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @PostMapping("/base/pointMerchars/getRedeemedNums") |
| | | public int getRedeemedQuantity(@RequestBody Integer goodId){ |
| | | return upmseService.count(new QueryWrapper<UserPointsMerchandise>() |
| | | .eq("pointsMerchandiseId",goodId)); |
| | | } |
| | | |
| | | } |