gc-shop/src/main/java/com/xzx/gc/shop/dto/AddGoodsDto.java
@@ -67,6 +67,9 @@ @ApiModelProperty(value="碳排放量",required=true) private Integer carbonEmissions; @ApiModelProperty(value="限购次数") private Integer quotaTime; @ApiModelProperty(value="主图") private List<String> goodsImages; gc-shop/src/main/java/com/xzx/gc/shop/dto/UpdateGoodsDto.java
@@ -64,6 +64,9 @@ @ApiModelProperty(value="碳排放量",required=true) private Integer carbonEmissions; @ApiModelProperty(value="限购次数") private Integer quotaTime; @ApiModelProperty(value="积分商品轮播图") private List<String> goodsImages; gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreOrderMapper.java
@@ -33,4 +33,8 @@ Integer selectScoreOrderCnt(@Param("userId") String userId); Integer selectGoodsQuotaTime(@Param("userId")String userId, @Param("goodsId")Long id, @Param("qgStartTime")Date qgStartTime, @Param("qgEndTime")Date qgEndTime); } gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
@@ -46,6 +46,8 @@ ScoreGoodsStyleMapper scoreGoodsStyleMapper; @Resource ScoreGoodsSearchMapper scoreGoodsSearchMapper; @Resource ScoreOrderMapper scoreOrderMapper; @Autowired private MqUtil mqUtil; @@ -327,6 +329,19 @@ PageHelper.startPage(xcxGoodsListDto.getPageNo(), xcxGoodsListDto.getPageSize()); List<XcxGoodsListVo> data = scoreGoodsMapper.selectXcxGoodsList(xcxGoodsListDto); if(StrUtil.isNotEmpty(xcxGoodsListDto.getUserId())){ if(CollUtil.isNotEmpty(data)){ for(XcxGoodsListVo xcxGoodsListVo : data){ if(ScoreGoods.ISQG_YES == xcxGoodsListVo.getIsQg()){ //抢购时间内,用户购买该商品的数量 Integer sumCnt = scoreOrderMapper.selectGoodsQuotaTime(xcxGoodsListDto.getUserId(),xcxGoodsListVo.getId(),xcxGoodsListVo.getQgStartTime(),xcxGoodsListVo.getQgEndTime()); xcxGoodsListVo.setAvaQuotaTime( ((xcxGoodsListVo.getQuotaTime() == null?0:xcxGoodsListVo.getQuotaTime()) - sumCnt) > 0?((xcxGoodsListVo.getQuotaTime() == null?0:xcxGoodsListVo.getQuotaTime()) - sumCnt):0 ); } } } } if(StrUtil.isNotEmpty(xcxGoodsListDto.getName())){ Example exampleSearch = new Example(ScoreGoodsSearch.class); Example.Criteria criteriaSearch = exampleSearch.createCriteria(); gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java
@@ -229,7 +229,33 @@ throw new RestException(-3, "积分不足"); } BigDecimal totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt())); BigDecimal totalPrice = BigDecimal.ZERO; if (ScoreGoods.ISQG_YES.equals(goods.getIsQg())) { //限购数量 Integer quotaTime = goods.getQuotaTime() == null ? 0:goods.getQuotaTime(); //抢购时间内,用户购买该商品的数量 Integer sumCnt = scoreOrderMapper.selectGoodsQuotaTime(addGoodsOrderDto.getUserId(),goods.getId(),goods.getQgStartTime(),goods.getQgEndTime()); //剩余限购数量 quotaTime = quotaTime-sumCnt; if(goods.getQgStartTime().before(new Date()) && goods.getQgEndTime().after(new Date())){ if(addGoodsOrderDto.getCnt() <= quotaTime){ totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(quotaTime)); }else{ if(quotaTime > 0){ totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(quotaTime)).add( sku.getOriginalPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt()-quotaTime))); }else{ totalPrice = sku.getOriginalPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt())); } } }else{ //开启抢购,不再时间内,直接原价* 数量 totalPrice = sku.getOriginalPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt())); } }else{ //没有开启抢购,直接现价* 数量 totalPrice = sku.getPresentPrice().multiply(BigDecimal.valueOf(addGoodsOrderDto.getCnt())); } BigDecimal score = new BigDecimal(accountInfo.getCollectScore()); if (score.compareTo(totalPrice) < 0) { throw new RestException(-3, "积分不足"); gc-shop/src/main/java/com/xzx/gc/shop/vo/ViewGoodsVo.java
@@ -68,6 +68,9 @@ @ApiModelProperty(value="碳排放量",required=true) private Integer carbonEmissions; @ApiModelProperty(value="限购次数") private Integer quotaTime; @ApiModelProperty(value="积分商品轮播图") private List<String> goodsImages; gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailVo.java
@@ -57,6 +57,12 @@ @ApiModelProperty(value = "剩余时间") private Long remainTime; @ApiModelProperty(value = "限购数量") private Integer quotaTime; @ApiModelProperty(value = "剩余限购数量") private Integer avaQuotaTime; @ApiModelProperty(value = "样式") private List<XcxGoodsDetailStyleVo> styles; gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsListVo.java
@@ -1,8 +1,11 @@ package com.xzx.gc.shop.vo; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; @Data @ApiModel(value = "XcxGoodsListVo", description = "小程序商品列表返回参数类") @@ -29,6 +32,18 @@ @ApiModelProperty(value = "库存") private Integer stock; @ApiModelProperty(value = "限购数量") private Integer quotaTime; @ApiModelProperty(value = "剩余限购数量") private Integer avaQuotaTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date qgStartTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date qgEndTime; @ApiModelProperty(value = "是否抢购 1-是 2-否") private Integer isQg; } gc-shop/src/main/resources/mapper/shop/ScoreOrderMapper.xml
@@ -127,4 +127,19 @@ and user_id=#{userId} </if> </select> <select id="selectGoodsQuotaTime" resultType="java.lang.Integer"> SELECT IFNULL(SUM(a.cnt), 0) FROM xzx_score_order a LEFT JOIN xzx_score_order_details b ON b.order_id = a.id WHERE a. STATUS IN (1, 2, 3, 4, 5) and a.user_id = #{userId} AND b.goods_id = #{goodsId} and a.CREATED_TIME >= qgStartTime and a.CREATED_TIME <= qgEndTime </select> </mapper> gc-shop/src/main/resources/sql
@@ -95,6 +95,17 @@ PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='首页弹窗表'; ALTER TABLE `xzx_score_goods` ADD COLUMN `quota_time` int(11) NULL COMMENT '限购次数' AFTER `present_price`; ALTER TABLE `xzx_jhy_order` ADD COLUMN `unit_name` varchar(32) NULL COMMENT '单元栋' AFTER `username`; ALTER TABLE `xzx_jhy_order` ADD COLUMN `house_number` varchar(32) NULL COMMENT '门牌号' AFTER `unit_name`; gc-shop/src/test/java/com/xzx/gc/CodeTest.java
New file @@ -0,0 +1,101 @@ package com.xzx.gc; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.github.pagehelper.PageHelper; import com.xzx.gc.common.constant.Constants; import com.xzx.gc.entity.AddressInfo; import com.xzx.gc.shop.dto.QueryGoodsListDto; import com.xzx.gc.shop.dto.QueryJhyOrderListDto; import com.xzx.gc.shop.mapper.JhyOrderItemsMapper; import com.xzx.gc.shop.mapper.JhyOrderMapper; import com.xzx.gc.shop.mapper.ScoreGoodsMapper; import com.xzx.gc.shop.vo.JhyOrderItemsVo; import com.xzx.gc.shop.vo.QueryGoodsListVo; import com.xzx.gc.shop.vo.QueryJhyOrderListVo; import lombok.extern.slf4j.Slf4j; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; @Slf4j @RunWith(SpringRunner.class) @SpringBootTest(classes = {GcShopApplication.class}) @ActiveProfiles("dev") public class CodeTest { @Autowired private ScoreGoodsMapper scoreGoodsMapper; @Autowired private JhyOrderMapper jhyOrderMapper; @Autowired private JhyOrderItemsMapper jhyOrderItemsMapper; @Test public void goodsList(){ QueryGoodsListDto model = new QueryGoodsListDto(); String name = model.getName() == null ? "":model.getName(); int delFlag = model.getDelFlag() == null ? 2:model.getDelFlag(); int namePx = model.getNamePx() == null ? 7:model.getNamePx(); int typePx = model.getTypePx() == null ? 2:model.getTypePx(); PageHelper.startPage(model.getPage(), model.getLimit()); List<QueryGoodsListVo> maps = scoreGoodsMapper.queryGoodsList(name,delFlag,1,1,namePx,typePx); System.out.println(maps.toString()); } @Test public void jhyOrderList(){ QueryJhyOrderListDto model = new QueryJhyOrderListDto(); List<Integer> status = new ArrayList<>(); if(CollUtil.isEmpty(model.getStatus())){ status.add(1); status.add(2); status.add(3); status.add(4); status.add(5); status.add(6); model.setStatus(status); } List<QueryJhyOrderListVo> maps = jhyOrderMapper.queryOrderList(model); if(CollUtil.isNotEmpty(maps)){ for(QueryJhyOrderListVo queryJhyOrderListVo : maps){ Long id = queryJhyOrderListVo.getId(); List<JhyOrderItemsVo> jhyOrderItemsVos = jhyOrderItemsMapper.selectByOrderId(id); queryJhyOrderListVo.setJhyOrderItemsVos(jhyOrderItemsVos); String orderAddr = queryJhyOrderListVo.getAddress(); Long userId = queryJhyOrderListVo.getUserId(); List<AddressInfo> addressInfos = jhyOrderMapper.selectAddRessInfoByUserId(userId); if(CollUtil.isNotEmpty(addressInfos)){ for(AddressInfo addressInfo : addressInfos){ StringBuffer address = new StringBuffer(); address.append(addressInfo.getDetailAddress()); if (StrUtil.isNotBlank(addressInfo.getTagName())) { address.append(StrUtil.isNotBlank(addressInfo.getHouseName()) ? addressInfo.getHouseName() : ""); if (Constants.ADDRESS_TYPE_HOME.equals(addressInfo.getTagName())) { address.append(StrUtil.isNotBlank(addressInfo.getHouseNumber()) ? addressInfo.getHouseNumber() : ""); address.append(StrUtil.isNotBlank(addressInfo.getUnitName()) ? addressInfo.getUnitName() : ""); } } if (orderAddr.equals(addressInfo.getAddressArea() + address)) { queryJhyOrderListVo.setUnitName(addressInfo.getUnitName()); System.out.println(orderAddr); queryJhyOrderListVo.setHouseNumber(addressInfo.getHouseNumber()); } } } } } } } gc-user/src/test/java/CodeTest.java
@@ -26,6 +26,8 @@ import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import com.aliyuncs.exceptions.ClientException; import com.github.pagehelper.PageHelper; import com.xzx.gc.GcUserApplication; import com.xzx.gc.common.Result; import com.xzx.gc.common.constant.Constants; import com.xzx.gc.common.constant.OrderEnum; @@ -38,20 +40,26 @@ import com.xzx.gc.common.utils.gdmap.GdTraceUtil; import com.xzx.gc.common.utils.image.QrCodeBaseUtils; import com.xzx.gc.common.utils.image.QrCodeGraphicsUtils; import com.xzx.gc.entity.AddressInfo; import com.xzx.gc.entity.HomeServiceInfo; import com.xzx.gc.entity.PartnerFence; import com.xzx.gc.entity.UserInfo; import com.xzx.gc.entity.*; import com.xzx.gc.user.dto.JhyInfoListDto; import com.xzx.gc.user.service.JhyInfoService; import com.xzx.gc.user.vo.JhyInfoListVo; import com.xzx.gc.util.BeanUtils; import lombok.Data; import lombok.extern.slf4j.Slf4j; import net.coobird.thumbnailator.Thumbnails; import org.apache.commons.lang3.RandomStringUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.locationtech.spatial4j.context.SpatialContext; import org.locationtech.spatial4j.distance.DistanceUtils; import org.locationtech.spatial4j.shape.Rectangle; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import sun.misc.Regexp; import tk.mybatis.mapper.entity.Example; import javax.imageio.ImageIO; import java.awt.*; @@ -71,8 +79,25 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; @Slf4j @RunWith(SpringRunner.class) @SpringBootTest(classes = {GcUserApplication.class}) @ActiveProfiles("dev") public class CodeTest { @Autowired private JhyInfoService jhyInfoService; @Test public void jhyList(){ JhyInfoListDto jhyInfoListDto = new JhyInfoListDto(); jhyInfoListDto.setPage(1); jhyInfoListDto.setLimit(10); jhyInfoListDto.setIsJhy(1); Map<String, Object> stringObjectMap = jhyInfoService.queryList(jhyInfoListDto); System.out.println(stringObjectMap.get("date")); } @Test @@ -137,30 +162,32 @@ @Test public void ex(){ Map<String, Object> row1 = new LinkedHashMap<>(); row1.put("姓名", "张三"); row1.put("年龄", 23); row1.put("成绩", 88.32); row1.put("是否合格", true); row1.put("考试日期", DateUtil.date()); Map<String, Object> row2 = new LinkedHashMap<>(); row2.put("姓名", "李四"); row2.put("年龄", 33); row2.put("成绩", 59.50); row2.put("是否合格", false); row2.put("考试日期", DateUtil.date()); ArrayList<Map<String, Object>> rows = CollUtil.newArrayList(row1, row2); System.out.println(rows); ArrayList<Map<String, Object>> rows = new ArrayList<>(); String str = null; for(int i = 0;i < 100000;i++){ Map<String, Object> row1 = new LinkedHashMap<>(); // str = "M0"+RandomUtil.randomString(8).toUpperCase(); // str = "M1"+RandomUtil.randomString(8).toUpperCase(); // str = "M2"+RandomUtil.randomString(8).toUpperCase(); // str = "M3"+RandomUtil.randomString(8).toUpperCase(); // str = "M4"+RandomUtil.randomString(8).toUpperCase(); // str = "M5"+RandomUtil.randomString(8).toUpperCase(); // str = "M6"+RandomUtil.randomString(8).toUpperCase(); // str = "M7"+RandomUtil.randomString(8).toUpperCase(); // str = "M8"+RandomUtil.randomString(8).toUpperCase(); str = "M9"+RandomUtil.randomString(8).toUpperCase(); row1.put("编码", str); rows.add(row1); } Set<Map<String, Object>> maps = RandomUtil.randomEleSet(rows, 10000); System.out.println(maps); // 通过工具类创建writer ExcelWriter writer = ExcelUtil.getWriter("d:/writeMapTest.xlsx"); ExcelWriter writer = ExcelUtil.getWriter("d:/编码M9.xlsx"); // 合并单元格后的标题行,使用默认标题样式 writer.merge(row1.size() - 1, "一班成绩单"); // writer.merge(maps.size() - 1, "编码"); // 一次性写出内容,使用默认样式,强制输出标题 writer.write(rows, true); writer.write(maps, true); // 关闭writer,释放内存 writer.close();