| | |
| | | .collect(Collectors.toList()); |
| | | } |
| | | } |
| | | Pageable pageable = PageRequest.of(request.getPageNum() - 1, request.getPageSize()); |
| | | Page<Goods> page = getPage(goods, pageable); |
| | | return page.getContent(); |
| | | |
| | | //当前第几页 |
| | | int pageNo = request.getPageNum(); |
| | | //一页五条 |
| | | int size = request.getPageSize(); |
| | | |
| | | //分页 |
| | | goods = goods.stream().skip((pageNo - 1) * size).limit(size). |
| | | collect(Collectors.toList()); |
| | | return goods; |
| | | } |
| | | |
| | | // 对数据进行分页处理的方法 |
| | |
| | | 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.other.RegionClient; |
| | | 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.model.CouponListVo; |
| | | import com.dsh.activity.model.request.CommodityRequest; |
| | |
| | | |
| | | @Resource |
| | | private StoreClient stoClient; |
| | | |
| | | |
| | | @Resource |
| | | private RegionClient regionClient; |
| | | |
| | | @Resource |
| | | private CouponStoreService couStoreService; |
| | |
| | | if (dataVo.getUserType() == 1){ |
| | | coupon.setCityManagerId(dataVo.getCityManagerId()); |
| | | } |
| | | return couponService.save(coupon); |
| | | boolean save = couponService.save(coupon); |
| | | if (save){ |
| | | if (dataVo.getCompany() == 2){ |
| | | for (Integer storeId : dataVo.getStoreIds()) { |
| | | CouponStore couponStore = new CouponStore(); |
| | | couponStore.setCouponId(coupon.getId()); |
| | | couponStore.setStoreId(storeId); |
| | | couStoreService.save(couponStore); |
| | | } |
| | | } |
| | | List<Integer> cityIds = dataVo.getCityIds(); |
| | | if (dataVo.getCompany() == 3 && cityIds.size() > 0 ){ |
| | | List<CityDataAndProvinceDataVo> cityAndProvince = regionClient.getCityAndProvince(cityIds); |
| | | for (CityDataAndProvinceDataVo cityId : cityAndProvince) { |
| | | CouponCity couponCity = new CouponCity(); |
| | | couponCity.setCouponId(coupon.getId()); |
| | | couponCity.setCityCode(cityId.getCityCode()); |
| | | couponCity.setCity(cityId.getCityName()); |
| | | couponCity.setProvinceCode(cityId.getProvinceCode()); |
| | | couponCity.setProvince(cityId.getProvinceName()); |
| | | cityService.save(couponCity); |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | }catch (Exception e){ |
| | | return false; |
| | | } |
| | |
| | | CoursePackage coursePackage = cpClient.queryCoursePackageById(merchandise.getCoursePackageId()); |
| | | |
| | | detailsVo.setGoodId(coursePackage.getId()); |
| | | List<String> list1 = Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ",")); |
| | | List<String> list1 = new ArrayList<>(); |
| | | list1.add(coursePackage.getCoverDrawing()); |
| | | list1.addAll(Arrays.asList(StrUtils.splitStr2StrArr(coursePackage.getDetailDrawing(), ","))); |
| | | detailsVo.setPics(list1); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(coursePackage.getCoverDrawing())) { |
| | |
| | | case 3: |
| | | |
| | | detailsVo.setGoodId(merchandise.getId()); |
| | | List<String> list2 = Arrays.asList(StrUtils.splitStr2StrArr(merchandise.getProductImages(), ",")); |
| | | list2.add(merchandise.getCover()); |
| | | List<String> list2 = new ArrayList<>(); |
| | | String cover = merchandise.getCover(); |
| | | list2.add(cover); |
| | | list2.addAll(Arrays.asList(StrUtils.splitStr2StrArr(merchandise.getProductImages(), ","))); |
| | | detailsVo.setPics(list2); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(merchandise.getCover())) { |
| | |
| | | // 优惠券 |
| | | Coupon coupon = iCouponService.getById(detailRequest.getGoodId()); |
| | | detailsVo.setGoodId(coupon.getId()); |
| | | List<String> list3 = Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")); |
| | | List<String> list3 = new ArrayList<>(); |
| | | list3.add(coupon.getCover()); |
| | | list3.addAll(Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ","))); |
| | | detailsVo.setPics(list3); |
| | | Collections.sort(detailsVo.getPics(), (s1, s2) -> { |
| | | if (s1.equals(coupon.getCover())) { |
New file |
| | |
| | | package com.dsh.activity.feignclient.other; |
| | | |
| | | |
| | | import com.dsh.activity.feignclient.other.model.CityDataAndProvinceDataVo; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | @FeignClient("mb-cloud-other") |
| | | public interface RegionClient { |
| | | |
| | | |
| | | @PostMapping("/base/region/getCityAndProvince") |
| | | public List<CityDataAndProvinceDataVo> getCityAndProvince(List<Integer> ids); |
| | | } |
New file |
| | |
| | | package com.dsh.activity.feignclient.other.model; |
| | | |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class CityDataAndProvinceDataVo { |
| | | |
| | | String cityName; |
| | | |
| | | String cityCode; |
| | | |
| | | String provinceName; |
| | | |
| | | String provinceCode; |
| | | |
| | | } |
| | |
| | | <el-upload |
| | | class="avatar-uploader" |
| | | action="/tCouponManage/uploadPic" |
| | | :show-file-list="false" |
| | | :on-success="handleAvatarSuccess" |
| | | accept=".jpg,.jpeg,.png,.JPG,.JPEG" |
| | | :on-remove="handleRemove" |
| | | :before-upload="beforeAvatarUpload"> |
| | | <img v-if="imageUrl" :src="imageUrl" class="avatar"> |
| | |
| | | class="avatar-uploader" |
| | | action="/tCouponManage/uploadPic" |
| | | list-type="picture-card" |
| | | accept="." |
| | | accept=".jpg,.jpeg,.png,.JPG,.JPEG" |
| | | :on-success="handleAvatarSuccess" |
| | | :on-remove="handleRemove"> |
| | | <i class="el-icon-plus"></i> |
| | |
| | | data: { |
| | | autoUpload: true,//自动上传 |
| | | imageUrl: '',//模型数据,用于上传图片完成后图片预览 |
| | | dialogVisible: false |
| | | }, |
| | | methods: { |
| | | handleAvatarSuccess(res, file) { |
| | | couponInfoDlg.goodsCover = URL.createObjectURL(file.raw); |
| | | this.imageUrl = URL.createObjectURL(file.raw); |
| | | couponInfoDlg.goodsCover = file.response; |
| | | }, |
| | | beforeAvatarUpload(file) { |
| | | const isLt2M = file.size / 1024 / 1024 < 10; |
| | |
| | | }, |
| | | handleRemove(file, fileList) { |
| | | couponInfoDlg.goodsCover = ''; |
| | | console.log(couponInfoDlg.goodsCover) |
| | | }, |
| | | }, |
| | | created() { |
| | |
| | | |
| | | var vue2 = new Vue({ |
| | | el: '#app1', |
| | | props: { |
| | | // 数量限制 |
| | | limit: { |
| | | type: Number, |
| | | default: 2 |
| | | }, |
| | | }, |
| | | data: { |
| | | autoUpload: true,//自动上传 |
| | | imageUrl1: '',//模型数据,用于上传图片完成后图片预览 |
| | |
| | | var couponInfoDlg = { |
| | | couponInfoData: {}, |
| | | goodsPicArray: [], //商品图片数组 |
| | | goodsCover: '' //商品封面图 |
| | | goodsCover: '', //商品封面图 |
| | | storeIds: [], |
| | | }; |
| | | |
| | | /** |
| | |
| | | |
| | | var num = 0; |
| | | couponInfoDlg.addBranch = function () { |
| | | num=num+1; |
| | | var a= ""; |
| | | a = "<div style=\'margin-left: 25%\' class=\"col-sm-9 control-label\">\n" + |
| | | " <select class=\"col-sm-1\" id=\'provinceData"+num+"\' style=\"margin-top: 1%;width: 25%\" onchange=\'changeCity("+num+")\'>\n" + |
| | |
| | | " </div>"; |
| | | $("#cityDemo").append($(a)); |
| | | getProvince(num); |
| | | num=num+1 |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | couponInfoDlg.addSubmit = function () { |
| | | |
| | | var resultData = {}; |
| | | var cityIds = []; |
| | | // 优惠券名称 |
| | | var couponName = $('#name').val(); |
| | | // 优惠券类型 |
| | |
| | | let exchangeMethod = $(':radio[name="exchangeMethod"]:checked').val(); |
| | | |
| | | var requiredCash = $('#requiredCash').val(); |
| | | |
| | | var company = $('#company').val(); |
| | | if (company === '2'){ |
| | | var myselect=document.getElementById('cityData'); |
| | | var seCity = myselect.options[myselect.selectedIndex].value; |
| | | if (seCity === null || seCity === undefined || seCity === ''){ |
| | | return Feng.error('请选中一个省市'); |
| | | } |
| | | cityIds.push(seCity); |
| | | if (this.num > 0){ |
| | | for (let i = 1; i <= num; i++) { |
| | | var insSelect=document.getElementById('cityData'+i); |
| | | var inData = insSelect.options[insSelect.selectedIndex].value; |
| | | if (inData !== undefined || inData !== null || inData !== ''){ |
| | | cityIds.push(inData); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (company === '3'){ |
| | | |
| | | } |
| | | |
| | | console.log('11111111') |
| | | |
| | |
| | | ajax.set("goodImg",this.goodsCover); |
| | | ajax.set("goodImgs",this.goodsPicArray); |
| | | ajax.set("company",$('#company').val()); |
| | | ajax.set("cityIds",[]); |
| | | ajax.set("storeIds",[]); |
| | | ajax.set("cityIds",cityIds); |
| | | ajax.set("storeIds",this.storeIds); |
| | | ajax.start(); |
| | | |
| | | } |
| | |
| | | |
| | | function saveSelectStores(){ |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
New file |
| | |
| | | package com.dsh.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dsh.other.entity.Region; |
| | | import com.dsh.other.model.CityDataAndProvinceDataVo; |
| | | import com.dsh.other.service.IRegionService; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class TRegionController { |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private IRegionService regionService; |
| | | |
| | | |
| | | @PostMapping("/base/region/getCityAndProvince") |
| | | public List<CityDataAndProvinceDataVo> getCityAndProvince(@RequestBody List<Integer> ids){ |
| | | List<CityDataAndProvinceDataVo> cityDataAndProvinceDataVos = new ArrayList<>(); |
| | | try { |
| | | List<Region> list = regionService.list(new LambdaQueryWrapper<Region>() |
| | | .in(Region::getId, ids)); |
| | | if (list.size() > 0) { |
| | | for (Region region : list) { |
| | | CityDataAndProvinceDataVo dataVo = new CityDataAndProvinceDataVo(); |
| | | dataVo.setCityCode(region.getCode()); |
| | | dataVo.setCityName(region.getName()); |
| | | Region byId = regionService.getById(region.getParentId()); |
| | | dataVo.setProvinceCode(byId.getCode()); |
| | | dataVo.setProvinceName(byId.getName()); |
| | | cityDataAndProvinceDataVos.add(dataVo); |
| | | } |
| | | } |
| | | return cityDataAndProvinceDataVos; |
| | | }catch (Exception e){ |
| | | return cityDataAndProvinceDataVos; |
| | | } |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * 省市区三级联动 |
| | | * </p> |
| | | * |
| | | * @author 吕雪 |
| | | * @since 2019-12-30 |
| | | */ |
| | | @TableName("t_region") |
| | | public class Region extends Model<Region> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键ID |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | /** |
| | | * 城市名称 |
| | | */ |
| | | @TableField("name") |
| | | private String name; |
| | | |
| | | @TableField("code") |
| | | private String code; |
| | | |
| | | @TableField("citycode") |
| | | private String citycode; |
| | | /** |
| | | * 父级ID |
| | | */ |
| | | @TableField("parent_id") |
| | | private Integer parentId; |
| | | /** |
| | | * 英文名称 |
| | | */ |
| | | @TableField("english") |
| | | private String english; |
| | | |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(String code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public String getCitycode() { |
| | | return citycode; |
| | | } |
| | | |
| | | public void setCitycode(String citycode) { |
| | | this.citycode = citycode; |
| | | } |
| | | |
| | | public Integer getParentId() { |
| | | return parentId; |
| | | } |
| | | |
| | | public void setParentId(Integer parentId) { |
| | | this.parentId = parentId; |
| | | } |
| | | |
| | | public String getEnglish() { |
| | | return english; |
| | | } |
| | | |
| | | public void setEnglish(String english) { |
| | | this.english = english; |
| | | } |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "Region{" + |
| | | "id=" + id + |
| | | ", name=" + name + |
| | | ", code=" + code + |
| | | ", citycode=" + citycode + |
| | | ", parentId=" + parentId + |
| | | ", english=" + english + |
| | | "}"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dsh.other.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dsh.other.entity.Region; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface RegionMapper extends BaseMapper<Region> { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.model; |
| | | |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class CityDataAndProvinceDataVo { |
| | | |
| | | String cityName; |
| | | |
| | | String cityCode; |
| | | |
| | | String provinceName; |
| | | |
| | | String provinceCode; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.other.entity.Region; |
| | | |
| | | /** |
| | | * 字典服务 |
| | | * |
| | | * @author fengshuonan |
| | | * @date 2017-04-27 17:00 |
| | | */ |
| | | public interface IRegionService extends IService<Region> { |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.other.entity.Region; |
| | | import com.dsh.other.mapper.RegionMapper; |
| | | import com.dsh.other.service.IRegionService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service |
| | | public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> implements IRegionService { |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dsh.course.mapper.RegionMapper"> |
| | | |
| | | </mapper> |