yshop1.5版本新增秒杀功能,手机端新增H5支付,修复其他bug,导出最新sql

This commit is contained in:
hupeng
2019-12-17 18:48:13 +08:00
parent cf6c875062
commit 4a18e76373
45 changed files with 1673 additions and 194 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>yshop</artifactId>
<groupId>co.yixiang</groupId>
<version>1.4</version>
<version>1.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,18 +21,18 @@
<dependency>
<groupId>co.yixiang</groupId>
<artifactId>yshop-common</artifactId>
<version>1.4</version>
<version>1.5</version>
</dependency>
<dependency>
<groupId>co.yixiang</groupId>
<artifactId>yshop-tools</artifactId>
<version>1.4</version>
<version>1.5</version>
</dependency>
<dependency>
<groupId>co.yixiang</groupId>
<artifactId>yshop-mp</artifactId>
<version>1.4</version>
<version>1.5</version>
</dependency>
<!--jwt-->

View File

@ -0,0 +1,113 @@
package co.yixiang.modules.activity.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import co.yixiang.common.entity.BaseEntity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* <p>
* 商品秒杀产品表
* </p>
*
* @author xuwenbo
* @since 2019-12-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "YxStoreSeckill对象", description = "商品秒杀产品表")
public class YxStoreSeckill extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "商品秒杀产品表id")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "商品id")
private Integer productId;
@ApiModelProperty(value = "推荐图")
private String image;
@ApiModelProperty(value = "轮播图")
private String images;
@ApiModelProperty(value = "活动标题")
private String title;
@ApiModelProperty(value = "简介")
private String info;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "成本")
private BigDecimal cost;
@ApiModelProperty(value = "原价")
private BigDecimal otPrice;
@ApiModelProperty(value = "返多少积分")
private BigDecimal giveIntegral;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "库存")
private Integer stock;
@ApiModelProperty(value = "销量")
private Integer sales;
@ApiModelProperty(value = "单位名")
private String unitName;
@ApiModelProperty(value = "邮费")
private BigDecimal postage;
@ApiModelProperty(value = "内容")
private String description;
@ApiModelProperty(value = "开始时间")
private Integer startTime;
@ApiModelProperty(value = "结束时间")
private Integer stopTime;
@ApiModelProperty(value = "添加时间")
private String addTime;
@ApiModelProperty(value = "产品状态")
private Integer status;
@ApiModelProperty(value = "是否包邮")
private Integer isPostage;
@ApiModelProperty(value = "热门推荐")
private Integer isHot;
@ApiModelProperty(value = "删除 0未删除1已删除")
private Integer isDel;
@ApiModelProperty(value = "最多秒杀几个")
private Integer num;
@ApiModelProperty(value = "显示")
private Integer isShow;
private Date endTimeDate;
private Date startTimeDate;
}

View File

@ -0,0 +1,60 @@
package co.yixiang.modules.activity.mapper;
import co.yixiang.modules.shop.web.vo.YxStoreProductQueryVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import co.yixiang.modules.activity.entity.YxStoreSeckill;
import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam;
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 商品秒杀产品表 Mapper 接口
* </p>
*
* @author xuwenbo
* @since 2019-12-14
*/
@Repository
public interface YxStoreSeckillMapper extends BaseMapper<YxStoreSeckill> {
@Update("update yx_store_seckill set stock=stock-#{num}, sales=sales+#{num}" +
" where id=#{seckillId}")
int decStockIncSales(@Param("num") int num,@Param("seckillId") int seckillId);
@Select("SELECT c.id,c.image,c.price,c.title as storeName,c.is_show as isShow,c.cost," +
"c.is_postage as isPostage,c.postage,c.sales,c.stock,c.is_del as isDel" +
" FROM yx_store_seckill c " +
" WHERE c.id = #{id} ")
YxStoreProductQueryVo seckillInfo(int id);
/**
* 根据ID获取查询对象
* @param id
* @return
*/
YxStoreSeckillQueryVo getYxStoreSeckillById(Serializable id);
/**
* 获取分页对象
* @param page
* @param yxStoreSeckillQueryParam
* @return
*/
IPage<YxStoreSeckillQueryVo> getYxStoreSeckillPageList(@Param("page") Page page, @Param("param") YxStoreSeckillQueryParam yxStoreSeckillQueryParam);
@Select("select t.id, t.image, t.images, t.title, t.info, t.price, t.cost, t.sort, t.stock, t.sales, " +
"t.postage, t.description, t.status, t.num from yx_store_seckill t" +
"INNER JOIN yx_store_product s ON s.id=t.product_id " +
"WHERE t.is_show = 1 AND t.is_del = 0 AND t.start_time < unix_timestamp(now()) " +
"AND t.stop_time > unix_timestamp(now()) ORDER BY t.sort desc,t.id desc")
List<YxStoreSeckillQueryVo> getCombList(Page<YxStoreSeckill> pageModel, @Param("time") String time);
}

View File

@ -0,0 +1,17 @@
package co.yixiang.modules.activity.mapping;
import co.yixiang.mapper.EntityMapper;
import co.yixiang.modules.activity.entity.YxStoreSeckill;
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author hupeng
* @date 2019-12-17
*/
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface StoreSeckillMap extends EntityMapper<YxStoreSeckillQueryVo, YxStoreSeckill> {
}

View File

@ -0,0 +1,51 @@
package co.yixiang.modules.activity.service;
import co.yixiang.modules.activity.entity.YxStoreSeckill;
import co.yixiang.common.service.BaseService;
import co.yixiang.modules.activity.web.dto.StoreSeckillDTO;
import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam;
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
import co.yixiang.common.web.vo.Paging;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 商品秒杀产品表 服务类
* </p>
*
* @author xuwenbo
* @since 2019-12-14
*/
public interface YxStoreSeckillService extends BaseService<YxStoreSeckill> {
void decStockIncSales(int num,int seckillId);
YxStoreSeckill getSeckill(int id);
StoreSeckillDTO getDetail(int id) throws Exception;
/**
* 分页获取产品详情
* @param page
* @param limit
* @return
*/
List<YxStoreSeckillQueryVo> getList(int page, int limit, int startTime,int endTime);
/**
* 根据ID获取查询对象
* @param id
* @return
*/
YxStoreSeckillQueryVo getYxStoreSeckillById(Serializable id) throws Exception;
/**
* 获取分页对象
* @param yxStoreSeckillQueryParam
* @return
*/
Paging<YxStoreSeckillQueryVo> getYxStoreSeckillPageList(YxStoreSeckillQueryParam yxStoreSeckillQueryParam) throws Exception;
}

View File

@ -0,0 +1,132 @@
package co.yixiang.modules.activity.service.impl;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import co.yixiang.exception.ErrorRequestException;
import co.yixiang.modules.activity.entity.YxStoreCombination;
import co.yixiang.modules.activity.entity.YxStoreSeckill;
import co.yixiang.modules.activity.mapper.YxStoreSeckillMapper;
import co.yixiang.modules.activity.mapping.StoreSeckillMap;
import co.yixiang.modules.activity.service.YxStoreSeckillService;
import co.yixiang.modules.activity.web.dto.StoreSeckillDTO;
import co.yixiang.modules.activity.web.param.YxStoreSeckillQueryParam;
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.web.vo.Paging;
import co.yixiang.modules.shop.service.YxStoreProductReplyService;
import co.yixiang.utils.OrderUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 商品秒杀产品表 服务实现类
* </p>
*
* @author hupeng
* @since 2019-12-14
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMapper, YxStoreSeckill> implements YxStoreSeckillService {
@Autowired
private YxStoreSeckillMapper yxStoreSeckillMapper;
@Autowired
private StoreSeckillMap storeSeckillMap;
@Autowired
private YxStoreProductReplyService replyService;
/**
* 减库存增加销量
* @param num
* @param seckillId
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void decStockIncSales(int num, int seckillId) {
yxStoreSeckillMapper.decStockIncSales(num,seckillId);
}
@Override
public YxStoreSeckill getSeckill(int id) {
QueryWrapper<YxStoreSeckill> wrapper = new QueryWrapper<>();
int nowTime = OrderUtil.getSecondTimestampTwo();
wrapper.eq("id",id).eq("is_del",0).eq("status",1)
.le("start_time",nowTime).ge("stop_time",nowTime);
return yxStoreSeckillMapper.selectOne(wrapper);
}
/**
* 产品详情
* @param id
* @return
*/
@Override
public StoreSeckillDTO getDetail(int id) throws Exception{
YxStoreSeckillQueryVo yxStoreSeckillQueryVo = getYxStoreSeckillById(id);
if(ObjectUtil.isNull(yxStoreSeckillQueryVo)){
throw new ErrorRequestException("秒杀产品不存在或已下架");
}
StoreSeckillDTO storeSeckillDTO = StoreSeckillDTO.builder()
.storeInfo(yxStoreSeckillQueryVo)
.reply(replyService.getReply(yxStoreSeckillQueryVo.getProductId()))
.replyCount(replyService.productReplyCount(yxStoreSeckillQueryVo.getProductId()))
.build();
return storeSeckillDTO;
}
/**
* 秒杀产品列表
* @param page
* @param limit
* @param startTime
* @param endTime
* @return
*/
@Override
public List<YxStoreSeckillQueryVo> getList(int page, int limit,int startTime,int endTime) {
Page<YxStoreSeckill> pageModel = new Page<>(page, limit);
QueryWrapper<YxStoreSeckill> wrapper = new QueryWrapper<>();
wrapper.eq("is_del",0).eq("status",1)
.le("start_time",startTime).ge("stop_time",endTime).orderByDesc("sort");
List<YxStoreSeckillQueryVo> yxStoreSeckillQueryVos = storeSeckillMap
.toDto(yxStoreSeckillMapper.selectPage(pageModel,wrapper).getRecords());
yxStoreSeckillQueryVos.forEach(item->{
Integer sum = item.getSales() + item.getStock();
item.setPercent(NumberUtil.round(NumberUtil.mul(NumberUtil.div(item.getSales(),sum),
100),0).intValue());
});
return yxStoreSeckillQueryVos;
}
@Override
public YxStoreSeckillQueryVo getYxStoreSeckillById(Serializable id) throws Exception{
return yxStoreSeckillMapper.getYxStoreSeckillById(id);
}
@Override
public Paging<YxStoreSeckillQueryVo> getYxStoreSeckillPageList(YxStoreSeckillQueryParam yxStoreSeckillQueryParam) throws Exception{
Page page = setPageParam(yxStoreSeckillQueryParam,OrderItem.desc("create_time"));
IPage<YxStoreSeckillQueryVo> iPage = yxStoreSeckillMapper.getYxStoreSeckillPageList(page,yxStoreSeckillQueryParam);
return new Paging(iPage);
}
}

View File

@ -0,0 +1,138 @@
package co.yixiang.modules.activity.web.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.modules.activity.service.YxStoreSeckillService;
import co.yixiang.modules.activity.web.dto.SeckillConfigDTO;
import co.yixiang.modules.activity.web.dto.SeckillTimeDTO;
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
import co.yixiang.common.web.controller.BaseController;
import co.yixiang.common.api.ApiResult;
import co.yixiang.modules.shop.entity.YxSystemGroupData;
import co.yixiang.modules.shop.service.YxSystemGroupDataService;
import co.yixiang.utils.OrderUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* <p>
* 商品秒杀产品 前端控制器
* </p>
*
* @author xuwenbo
* @since 2019-12-14
*/
@Slf4j
@RestController
@RequestMapping
@Api(value = "商品秒杀", tags = "商品秒杀", description = "商品秒杀")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class StoreSeckillController extends BaseController {
private final YxStoreSeckillService yxStoreSeckillService;
private final YxSystemGroupDataService yxSystemGroupDataService;
/**
* 秒杀产品列表
*/
@GetMapping("/seckill/list/{time}")
@ApiOperation(value = "秒杀产品列表", notes = "秒杀产品列表", response = YxStoreSeckillQueryVo.class)
public ApiResult<Object> getYxStoreSeckillPageList(@PathVariable String time,
@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "limit", defaultValue = "10") int limit) throws Exception {
if(StrUtil.isBlank(time)) return ApiResult.fail("参数错误");
YxSystemGroupData systemGroupData = yxSystemGroupDataService
.findData(Integer.valueOf(time));
if(ObjectUtil.isNull(systemGroupData)) return ApiResult.fail("参数错误");
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));//今天开始的时间戳
JSONObject jsonObject = JSONObject.parseObject(systemGroupData.getValue());
int startTime = today + (jsonObject.getInteger("time") * 3600);
int endTime = today + ((jsonObject.getInteger("time")+jsonObject.getInteger("continued")) * 3600);
return ApiResult.ok(yxStoreSeckillService.getList(page,limit,startTime,endTime));
}
/**
* 根据id获取商品秒杀产品详情
*/
@GetMapping("/seckill/detail/{id}")
@ApiOperation(value = "获取YxStoreSeckill对象详情", notes = "查看商品秒杀产品表", response = YxStoreSeckillQueryVo.class)
public ApiResult<Object> getYxStoreSeckill(@PathVariable Integer id) throws Exception {
return ApiResult.ok(yxStoreSeckillService.getDetail(id));
}
/**
* 秒杀产品时间区间
*/
@GetMapping("/seckill/index")
@ApiOperation(value = "秒杀产品时间区间", notes = "秒杀产品时间区间", response = YxStoreSeckillQueryVo.class)
public ApiResult<Object> getYxStoreSeckillIndex() throws Exception {
//获取秒杀配置
AtomicInteger seckillTimeIndex = new AtomicInteger();
SeckillConfigDTO seckillConfigDTO = new SeckillConfigDTO();
List<YxSystemGroupData> yxSystemGroupDataList = yxSystemGroupDataService.list(new QueryWrapper<YxSystemGroupData>().eq("group_name", "routine_seckill_time"));
List<SeckillTimeDTO> list = new ArrayList<>();
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date()));
yxSystemGroupDataList.forEach(i -> {
String jsonStr = i.getValue();
JSONObject jsonObject = JSON.parseObject(jsonStr);
int time = Integer.valueOf(jsonObject.get("time").toString());//时间 5
int continued = Integer.valueOf(jsonObject.get("continued").toString());//活动持续事件 3
SimpleDateFormat sdf = new SimpleDateFormat("HH");
String nowTime = sdf.format(new Date());
String index = nowTime.substring(0, 1);
int currentHour = index.equals("0") ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime);
SeckillTimeDTO seckillseckillTimeDTO = new SeckillTimeDTO();
seckillseckillTimeDTO.setId(i.getId());
//活动结束时间
int activityEndHour = Integer.valueOf(time).intValue() + Integer.valueOf(continued).intValue();
if (activityEndHour > 24) {
seckillseckillTimeDTO.setState("即将开始");
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
seckillseckillTimeDTO.setStatus(2);
seckillseckillTimeDTO.setStop(today + activityEndHour * 3600);
} else {
if (currentHour >= time && currentHour < activityEndHour) {
seckillseckillTimeDTO.setState("抢购中");
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
seckillseckillTimeDTO.setStatus(1);
seckillseckillTimeDTO.setStop(today + activityEndHour * 3600);
seckillTimeIndex.set(yxSystemGroupDataList.indexOf(i));
} else if (currentHour < time) {
seckillseckillTimeDTO.setState("即将开始");
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
seckillseckillTimeDTO.setStatus(2);
seckillseckillTimeDTO.setStop(OrderUtil.dateToTimestamp(new Date()) + activityEndHour * 3600);
} else if (currentHour >= activityEndHour) {
seckillseckillTimeDTO.setState("已结束");
seckillseckillTimeDTO.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00");
seckillseckillTimeDTO.setStatus(0);
seckillseckillTimeDTO.setStop(today + activityEndHour * 3600);
}
}
list.add(seckillseckillTimeDTO);
});
seckillConfigDTO.setSeckillTimeIndex(seckillTimeIndex.get());
seckillConfigDTO.setSeckillTime(list);
return ApiResult.ok(seckillConfigDTO);
}
}

View File

@ -0,0 +1,17 @@
package co.yixiang.modules.activity.web.dto;
import lombok.Data;
import java.util.List;
@Data
public class SeckillConfigDTO {
private List<SeckillTimeDTO> seckillTime;
private String lovely;
private Integer seckillTimeIndex;
}

View File

@ -0,0 +1,21 @@
package co.yixiang.modules.activity.web.dto;
import lombok.Data;
@Data
public class SeckillTimeDTO {
private Integer id;
/**
* 00:00
*/
private String time;
/**
*状态
*/
private String state;
private Integer status;
private Integer stop;
}

View File

@ -0,0 +1,32 @@
package co.yixiang.modules.activity.web.dto;
import co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo;
import co.yixiang.modules.shop.web.vo.YxStoreProductReplyQueryVo;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 秒杀产品表 查询结果对象
* </p>
*
* @author hupeng
* @date 2019-12-17
*/
@Data
@Builder
public class StoreSeckillDTO implements Serializable {
private static final long serialVersionUID = 1L;
private YxStoreProductReplyQueryVo reply;
private Integer replyCount = 0;
private YxStoreSeckillQueryVo storeInfo;
}

View File

@ -0,0 +1,22 @@
package co.yixiang.modules.activity.web.param;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import co.yixiang.common.web.param.QueryParam;
/**
* <p>
* 商品秒杀产品表 查询参数对象
* </p>
*
* @author xuwenbo
* @date 2019-12-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="YxStoreSeckillQueryParam对象", description="商品秒杀产品表查询参数")
public class YxStoreSeckillQueryParam extends QueryParam {
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,120 @@
package co.yixiang.modules.activity.web.vo;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* <p>
* 商品秒杀产品表 查询结果对象
* </p>
*
* @author xuwenbo
* @date 2019-12-14
*/
@Data
@ApiModel(value="YxStoreSeckillQueryVo对象", description="商品秒杀产品表查询参数")
public class YxStoreSeckillQueryVo implements Serializable{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "商品秒杀产品表id")
private Integer id;
@ApiModelProperty(value = "商品id")
private Integer productId;
@ApiModelProperty(value = "推荐图")
private String image;
@ApiModelProperty(value = "轮播图")
private String images;
private List<String> sliderImageArr;
public List<String> getSliderImageArr() {
if(StrUtil.isNotEmpty(images)){
return Arrays.asList(images.split(","));
}else {
return new ArrayList<>();
}
}
@ApiModelProperty(value = "轮播图")
private String[] pics;
@ApiModelProperty(value = "活动标题")
private String title;
@ApiModelProperty(value = "简介")
private String info;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "成本")
private BigDecimal cost;
@ApiModelProperty(value = "原价")
private BigDecimal otPrice;
@ApiModelProperty(value = "返多少积分")
private BigDecimal giveIntegral;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "库存")
private Integer stock;
@ApiModelProperty(value = "销量")
private Integer sales;
@ApiModelProperty(value = "单位名")
private String unitName;
@ApiModelProperty(value = "邮费")
private BigDecimal postage;
@ApiModelProperty(value = "内容")
private String description;
@ApiModelProperty(value = "开始时间")
private Integer startTime;
@ApiModelProperty(value = "结束时间")
private Integer stopTime;
@ApiModelProperty(value = "添加时间")
private String addTime;
@ApiModelProperty(value = "产品状态")
private Integer status;
@ApiModelProperty(value = "是否包邮")
private Integer isPostage;
@ApiModelProperty(value = "热门推荐")
private Integer isHot;
@ApiModelProperty(value = "删除 0未删除1已删除")
private Integer isDel;
@ApiModelProperty(value = "最多秒杀几个")
private Integer num;
@ApiModelProperty(value = "显示")
private Integer isShow;
private Integer percent; //百分比
}

View File

@ -15,6 +15,7 @@ import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
import co.yixiang.common.web.vo.Paging;
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
import com.github.binarywang.wxpay.exception.WxPayException;
@ -81,6 +82,8 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
WxPayMpOrderResult wxPay(String orderId) throws WxPayException;
WxPayMwebOrderResult wxH5Pay(String orderId) throws WxPayException;
String aliPay(String orderId) throws Exception;
void delCacheOrderInfo(int uid, String key);

View File

@ -8,6 +8,7 @@ import co.yixiang.domain.vo.TradeVo;
import co.yixiang.exception.ErrorRequestException;
import co.yixiang.modules.activity.service.YxStoreCombinationService;
import co.yixiang.modules.activity.service.YxStorePinkService;
import co.yixiang.modules.activity.service.YxStoreSeckillService;
import co.yixiang.modules.manage.service.YxExpressService;
import co.yixiang.modules.manage.web.dto.ChartDataDTO;
import co.yixiang.modules.manage.web.dto.OrderDataDTO;
@ -59,6 +60,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.exception.WxPayException;
@ -150,6 +152,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
@Autowired
private YxStoreCombinationService combinationService;
@Autowired
private YxStoreSeckillService storeSeckillService;
@Autowired
private YxStorePinkService pinkService;
@ -936,6 +941,48 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
return payUrl;
}
@Override
public WxPayMwebOrderResult wxH5Pay(String orderId) throws WxPayException {
String apiUrl = systemConfigService.getData("api_url");
if(StrUtil.isBlank(apiUrl)) throw new ErrorRequestException("请配置api地址");
//读取redis配置
String appId = RedisUtil.get("wxpay_appId");
String mchId = RedisUtil.get("wxpay_mchId");
String mchKey = RedisUtil.get("wxpay_mchKey");
if(StrUtil.isBlank(appId) || StrUtil.isBlank(mchId) || StrUtil.isBlank(mchKey)){
throw new ErrorRequestException("请配置微信支付");
}
WxPayConfig wxPayConfig = new WxPayConfig();
wxPayConfig.setAppId(appId);
wxPayConfig.setMchId(mchId);
wxPayConfig.setMchKey(mchKey);
wxPayService.setConfig(wxPayConfig);
YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId,0);
if(ObjectUtil.isNull(orderInfo)) throw new ErrorRequestException("订单不存在");
if(orderInfo.getPaid() == 1) throw new ErrorRequestException("该订单已支付");
if(orderInfo.getPayPrice().doubleValue() <= 0) throw new ErrorRequestException("该支付无需支付");
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
YxUser wechatUser = userService.getById(orderInfo.getUid());
if(ObjectUtil.isNull(wechatUser)) throw new ErrorRequestException("用户错误");
orderRequest.setTradeType("MWEB");
orderRequest.setBody("商品购买");
orderRequest.setOutTradeNo(orderId);
BigDecimal bigDecimal = new BigDecimal(100);
orderRequest.setTotalFee(bigDecimal.multiply(orderInfo.getPayPrice()).intValue());//元转成分
orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl(apiUrl+"/api/wechat/notify");
WxPayMwebOrderResult orderResult = wxPayService.createOrder(orderRequest);
return orderResult;
}
/**
* 微信支付
* @param orderId
@ -967,14 +1014,15 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
YxWechatUser wechatUser = wechatUserService.getById(orderInfo.getUid());
if(ObjectUtil.isNull(wechatUser)) throw new ErrorRequestException("用户错误");
orderRequest.setTradeType("JSAPI");
orderRequest.setOpenid(wechatUser.getOpenid());
orderRequest.setBody("商品购买");
orderRequest.setOutTradeNo(orderId);
BigDecimal bigDecimal = new BigDecimal(100);
orderRequest.setTotalFee(bigDecimal.multiply(orderInfo.getPayPrice()).intValue());//元转成分
orderRequest.setOpenid(wechatUser.getOpenid());
orderRequest.setSpbillCreateIp("127.0.0.1");
orderRequest.setNotifyUrl(apiUrl+"/api/wechat/notify");
orderRequest.setTradeType("JSAPI");
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
@ -1055,14 +1103,16 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
Integer gainIntegral = 0;
List<String> cartIds = new ArrayList<>();
int combinationId = 0;
int seckillId = 0;
for (YxStoreCartQueryVo cart : cartInfo) {
combinationId = cart.getCombinationId();
seckillId = cart.getSeckillId();
cartIds.add(cart.getId().toString());
totalNum += cart.getCartNum();
//计算积分
BigDecimal cartInfoGainIntegral = BigDecimal.ZERO;
if(combinationId == 0 ){//拼团等活动不参与积分
if(combinationId == 0 && seckillId == 0){//拼团等活动不参与积分
if(cart.getProductInfo().getGiveIntegral().intValue() > 0){
cartInfoGainIntegral = NumberUtil.mul(cart.getCartNum(),cart.
getProductInfo().getGiveIntegral());
@ -1089,7 +1139,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
boolean deduction = false;//todo 拼团等
//拼团等不参与抵扣
if(combinationId > 0) deduction = true;
if(combinationId > 0 || seckillId > 0) deduction = true;
if(deduction){
couponId = 0;
useIntegral = 0;
@ -1175,7 +1225,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
storeOrder.setMark(param.getMark());
storeOrder.setCombinationId(combinationId);
storeOrder.setPinkId(param.getPinkId());
storeOrder.setSeckillId(0);
storeOrder.setSeckillId(seckillId);
storeOrder.setBargainId(0);
storeOrder.setCost(BigDecimal.valueOf(cacheDTO.getPriceGroup().getCostPrice()));
storeOrder.setIsChannel(param.getIsChannel());
@ -1190,7 +1240,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
for (YxStoreCartQueryVo cart : cartInfo) {
if(combinationId > 0){
combinationService.decStockIncSales(cart.getCartNum(),combinationId);
}else {
}else if(seckillId > 0){
storeSeckillService.decStockIncSales(cart.getCartNum(),seckillId);
} else {
productService.decProductStock(cart.getCartNum(),cart.getProductId(),
cart.getProductAttrUnique());
}
@ -1246,14 +1298,16 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
Double payPrice = cacheDTO.getPriceGroup().getTotalPrice();
Double payPostage = cacheDTO.getPriceGroup().getStorePostage();
boolean deduction = false;//todo 拼团等
boolean deduction = false;//拼团秒杀砍价
int combinationId = 0;
int seckillId = 0;
List<YxStoreCartQueryVo> cartInfo = cacheDTO.getCartInfo();
for (YxStoreCartQueryVo cart : cartInfo) {
combinationId = cart.getCombinationId();
seckillId = cart.getSeckillId();
}
//拼团等不参与抵扣
if(combinationId > 0) deduction = true;
if(combinationId > 0 || seckillId > 0) deduction = true;
if(deduction){

View File

@ -31,6 +31,7 @@ import co.yixiang.utils.SecurityUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.order.WxPayMwebOrderResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -96,7 +97,7 @@ public class StoreOrderController extends BaseController {
confirmOrderDTO.setUsableCoupon(couponUserService
.beUsableCoupon(uid,priceGroup.getTotalPrice()));
//todo 积分抵扣下个版本 已经do
//积分抵扣
OtherDTO other = new OtherDTO();
other.setIntegralRatio(systemConfigService.getData("integral_ratio"));
@ -108,8 +109,15 @@ public class StoreOrderController extends BaseController {
combinationId = cartQueryVo.getCombinationId();
}
//拼团砍价类产品不参与抵扣
if(combinationId > 0) confirmOrderDTO.setDeduction(true);
int secKillId = 0;
if(cartId.split(",").length == 1){
YxStoreCartQueryVo cartQueryVo = cartService.getYxStoreCartById(Integer
.valueOf(cartId));
secKillId = cartQueryVo.getSeckillId();
}
//拼团砍价秒杀类产品不参与抵扣
if(combinationId > 0 || secKillId > 0) confirmOrderDTO.setDeduction(true);
confirmOrderDTO.setAddressInfo(addressService.getUserDefaultAddress(uid));
@ -117,7 +125,7 @@ public class StoreOrderController extends BaseController {
confirmOrderDTO.setPriceGroup(priceGroup);
confirmOrderDTO.setOrderKey(storeOrderService.cacheOrderInfo(uid,cartInfo,
priceGroup,other));
//todo VIP会员
confirmOrderDTO.setUserInfo(userService.getYxUserById(uid));
@ -167,25 +175,32 @@ public class StoreOrderController extends BaseController {
if(StrUtil.isNotEmpty(orderId)){
switch (param.getPayType()){
case "weixin":
if(param.getFrom().equals("weixinh5")){//此此为支付宝支付
throw new ErrorRequestException("H5模式不支持微信支付请用公众号演示");
}
try {
map.put("status","WECHAT_PAY");
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
.wxPay(orderId);
//重新组装
Map<String,String> jsConfig = new HashMap<>();
jsConfig.put("appId",wxPayMpOrderResult.getAppId());
jsConfig.put("timestamp",wxPayMpOrderResult.getTimeStamp());
jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr());
jsConfig.put("package",wxPayMpOrderResult.getPackageValue());
jsConfig.put("signType",wxPayMpOrderResult.getSignType());
jsConfig.put("paySign",wxPayMpOrderResult.getPaySign());
orderDTO.setJsConfig(jsConfig);
map.put("result",orderDTO);
return ApiResult.ok(map,"订单创建成功");
if(param.getFrom().equals("weixinh5")){
WxPayMwebOrderResult wxPayMwebOrderResult = storeOrderService
.wxH5Pay(orderId);
log.info("wxPayMwebOrderResult:{}",wxPayMwebOrderResult);
jsConfig.put("mweb_url",wxPayMwebOrderResult.getMwebUrl());
orderDTO.setJsConfig(jsConfig);
map.put("result",orderDTO);
map.put("status","WECHAT_H5_PAY");
return ApiResult.ok(map);
}else{
map.put("status","WECHAT_PAY");
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
.wxPay(orderId);
jsConfig.put("appId",wxPayMpOrderResult.getAppId());
jsConfig.put("timestamp",wxPayMpOrderResult.getTimeStamp());
jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr());
jsConfig.put("package",wxPayMpOrderResult.getPackageValue());
jsConfig.put("signType",wxPayMpOrderResult.getSignType());
jsConfig.put("paySign",wxPayMpOrderResult.getPaySign());
orderDTO.setJsConfig(jsConfig);
map.put("result",orderDTO);
return ApiResult.ok(map,"订单创建成功");
}
} catch (WxPayException e) {
return ApiResult.fail(e.getMessage());
}
@ -230,24 +245,33 @@ public class StoreOrderController extends BaseController {
if(StrUtil.isNotEmpty(orderId)){
switch (param.getPaytype()){
case "weixin":
if(param.getFrom().equals("weixinh5")){
throw new ErrorRequestException("H5模式不支持微信支付请用公众号演示");
}
try {
map.put("status","WECHAT_PAY");
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
.wxPay(orderId);
//重新组装
Map<String,String> jsConfig = new HashMap<>();
jsConfig.put("appId",wxPayMpOrderResult.getAppId());
jsConfig.put("timestamp",wxPayMpOrderResult.getTimeStamp());
jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr());
jsConfig.put("package",wxPayMpOrderResult.getPackageValue());
jsConfig.put("signType",wxPayMpOrderResult.getSignType());
jsConfig.put("paySign",wxPayMpOrderResult.getPaySign());
orderDTO.setJsConfig(jsConfig);
map.put("result",orderDTO);
return ApiResult.ok(map);
if(param.getFrom().equals("weixinh5")){
WxPayMwebOrderResult wxPayMwebOrderResult = storeOrderService
.wxH5Pay(orderId);
log.info("wxPayMwebOrderResult:{}",wxPayMwebOrderResult);
jsConfig.put("mweb_url",wxPayMwebOrderResult.getMwebUrl());
orderDTO.setJsConfig(jsConfig);
map.put("result",orderDTO);
map.put("status","WECHAT_H5_PAY");
return ApiResult.ok(map);
}else{
map.put("status","WECHAT_PAY");
WxPayMpOrderResult wxPayMpOrderResult = storeOrderService
.wxPay(orderId);
//重新组装
jsConfig.put("appId",wxPayMpOrderResult.getAppId());
jsConfig.put("timestamp",wxPayMpOrderResult.getTimeStamp());
jsConfig.put("nonceStr",wxPayMpOrderResult.getNonceStr());
jsConfig.put("package",wxPayMpOrderResult.getPackageValue());
jsConfig.put("signType",wxPayMpOrderResult.getSignType());
jsConfig.put("paySign",wxPayMpOrderResult.getPaySign());
orderDTO.setJsConfig(jsConfig);
map.put("result",orderDTO);
return ApiResult.ok(map);
}
} catch (WxPayException e) {
return ApiResult.fail(e.getMessage());
}

View File

@ -115,6 +115,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/wechat/notify").anonymous()
.antMatchers("/wechat/serve").anonymous()
.antMatchers("/logistics").anonymous()
.antMatchers("/seckill/index").anonymous()
.antMatchers("/seckill/list/**").anonymous()
.antMatchers("/seckill/list/**").anonymous()
.antMatchers("/seckill/detail/*").anonymous()
// 支付宝回调
.antMatchers("/api/aliPay/return").anonymous()
.antMatchers("/api/aliPay/notify").anonymous()

View File

@ -22,4 +22,6 @@ public interface YxSystemGroupDataService extends BaseService<YxSystemGroupData>
List<Map<String,Object>> getDatas(String name);
YxSystemGroupData findData(Integer id);
}

View File

@ -4,8 +4,13 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.exception.ErrorRequestException;
import co.yixiang.modules.activity.entity.YxStoreCombination;
import co.yixiang.modules.activity.entity.YxStoreSeckill;
import co.yixiang.modules.activity.mapper.YxStoreCombinationMapper;
import co.yixiang.modules.activity.mapper.YxStoreSeckillMapper;
import co.yixiang.modules.activity.service.YxStoreCombinationService;
import co.yixiang.modules.activity.service.YxStoreSeckillService;
import co.yixiang.modules.order.entity.YxStoreOrder;
import co.yixiang.modules.order.service.YxStoreOrderService;
import co.yixiang.modules.shop.entity.YxStoreCart;
import co.yixiang.modules.shop.entity.YxStoreProductAttrValue;
import co.yixiang.modules.shop.mapper.YxStoreCartMapper;
@ -70,6 +75,15 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
@Autowired
private YxStoreCombinationMapper storeCombinationMapper;
@Autowired
private YxStoreSeckillService storeSeckillService;
@Autowired
private YxStoreOrderService storeOrderService;
@Autowired
private YxStoreSeckillMapper storeSeckillMapper;
@Autowired
private YxUserService userService;
@ -153,6 +167,8 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
YxStoreProductQueryVo storeProduct = null;
if(storeCart.getCombinationId() > 0){
storeProduct = storeCombinationMapper.combinatiionInfo(storeCart.getCombinationId());
}else if(storeCart.getSeckillId() > 0){
storeProduct = storeSeckillMapper.seckillInfo(storeCart.getSeckillId());
}else{
storeProduct = productService
.getYxStoreProductById(storeCart.getProductId());
@ -177,12 +193,17 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
}else{
storeProduct.setAttrInfo(productAttrValue);
//todo 设置真实价格
//设置真实价格
//设置VIP价格
double vipPrice = userService.setLevelPrice(
productAttrValue.getPrice().doubleValue(),uid);
double vipPrice = 0d;
if(storeCart.getCombinationId() > 0 || storeCart.getSeckillId() > 0){
vipPrice = productAttrValue.getPrice().doubleValue();
}else{
vipPrice = userService.setLevelPrice(
productAttrValue.getPrice().doubleValue(),uid);
}
storeCartQueryVo.setTruePrice(vipPrice);
//todo 设置会员价
//设置会员价
storeCartQueryVo.setVipTruePrice(productAttrValue.getPrice()
.doubleValue());
storeCartQueryVo.setCostPrice(productAttrValue.getCost()
@ -193,8 +214,15 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
}
}else{
//设置VIP价格
double vipPrice = userService.setLevelPrice(
storeProduct.getPrice().doubleValue(),uid);
//设置VIP价格
double vipPrice = 0d;
if(storeCart.getCombinationId() > 0 || storeCart.getSeckillId() > 0){
vipPrice = storeProduct.getPrice().doubleValue();
}else{
vipPrice = userService.setLevelPrice(
storeProduct.getPrice().doubleValue(),uid);
}
storeCartQueryVo.setTruePrice(vipPrice);
//todo 设置会员价
storeCartQueryVo.setVipTruePrice(0d);
@ -236,6 +264,20 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
YxStoreCombination storeCombination = storeCombinationService.getCombination(combinationId);
if(ObjectUtil.isNull(storeCombination)) throw new ErrorRequestException("该产品已下架或删除");
}else if(seckillId > 0){//秒杀
YxStoreSeckill yxStoreSeckill = storeSeckillService.getSeckill(seckillId);
if(ObjectUtil.isNull(yxStoreSeckill)){
throw new ErrorRequestException("该产品已下架或删除");
}
if(yxStoreSeckill.getStock() < cartNum){
throw new ErrorRequestException("该产品库存不足");
}
int seckillOrderCount = storeOrderService.count(new QueryWrapper<YxStoreOrder>()
.eq("uid", uid).eq("paid",1).eq("seckill_id",seckillId));
if(yxStoreSeckill.getNum() <= seckillOrderCount || yxStoreSeckill.getNum() < cartNum){
throw new ErrorRequestException("每人限购:"+yxStoreSeckill.getNum()+"");
}
}else{
YxStoreProductQueryVo productQueryVo = productService
.getYxStoreProductById(productId);
@ -263,7 +305,6 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
storeCart.setBargainId(bargainId);
storeCart.setCartNum(cartNum);
storeCart.setCombinationId(combinationId);
storeCart.setIsNew(0);
storeCart.setProductAttrUnique(productAttrUnique);
storeCart.setProductId(productId);
storeCart.setSeckillId(seckillId);

View File

@ -60,7 +60,13 @@ public class YxSystemGroupDataServiceImpl extends BaseServiceImpl<YxSystemGroupD
return list;
}
/**
* 获取单条数据
* @param id
* @return
*/
@Override
public YxSystemGroupData findData(Integer id) {
return baseMapper.selectById(id);
}
}

View File

@ -88,8 +88,14 @@ public class StoreCartController extends BaseController {
combinationId = jsonObject.getInteger("combinationId");
}
//秒杀
int seckillId = 0;
if(ObjectUtil.isNotNull(jsonObject.get("secKillId"))){
seckillId = jsonObject.getInteger("secKillId");
}
map.put("cartId",storeCartService.addCart(uid,productId,cartNum,uniqueId
,"product",isNew,combinationId,0,0));
,"product",isNew,combinationId,seckillId,0));
return ApiResult.ok(map);
}

View File

@ -1,91 +0,0 @@
package co.yixiang.modules.user.web.controller;
import co.yixiang.modules.user.entity.YxUserRecharge;
import co.yixiang.modules.user.service.YxUserRechargeService;
import co.yixiang.modules.user.web.param.YxUserRechargeQueryParam;
import co.yixiang.modules.user.web.vo.YxUserRechargeQueryVo;
import co.yixiang.common.web.controller.BaseController;
import co.yixiang.common.api.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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 javax.validation.Valid;
import co.yixiang.common.web.vo.Paging;
import co.yixiang.common.web.param.IdParam;
/**
* <p>
* 用户充值表 前端控制器
* </p>
*
* @author hupeng
* @since 2019-12-08
*/
@Slf4j
@RestController
@RequestMapping("/yxUserRecharge")
@Api("用户充值表 API")
public class YxUserRechargeController extends BaseController {
@Autowired
private YxUserRechargeService yxUserRechargeService;
/**
* 添加用户充值表
*/
@PostMapping("/add")
@ApiOperation(value = "添加YxUserRecharge对象",notes = "添加用户充值表",response = ApiResult.class)
public ApiResult<Boolean> addYxUserRecharge(@Valid @RequestBody YxUserRecharge yxUserRecharge) throws Exception{
boolean flag = yxUserRechargeService.save(yxUserRecharge);
return ApiResult.result(flag);
}
/**
* 修改用户充值表
*/
@PostMapping("/update")
@ApiOperation(value = "修改YxUserRecharge对象",notes = "修改用户充值表",response = ApiResult.class)
public ApiResult<Boolean> updateYxUserRecharge(@Valid @RequestBody YxUserRecharge yxUserRecharge) throws Exception{
boolean flag = yxUserRechargeService.updateById(yxUserRecharge);
return ApiResult.result(flag);
}
/**
* 删除用户充值表
*/
@PostMapping("/delete")
@ApiOperation(value = "删除YxUserRecharge对象",notes = "删除用户充值表",response = ApiResult.class)
public ApiResult<Boolean> deleteYxUserRecharge(@Valid @RequestBody IdParam idParam) throws Exception{
boolean flag = yxUserRechargeService.removeById(idParam.getId());
return ApiResult.result(flag);
}
/**
* 获取用户充值表
*/
@PostMapping("/info")
@ApiOperation(value = "获取YxUserRecharge对象详情",notes = "查看用户充值表",response = YxUserRechargeQueryVo.class)
public ApiResult<YxUserRechargeQueryVo> getYxUserRecharge(@Valid @RequestBody IdParam idParam) throws Exception{
YxUserRechargeQueryVo yxUserRechargeQueryVo = yxUserRechargeService.getYxUserRechargeById(idParam.getId());
return ApiResult.ok(yxUserRechargeQueryVo);
}
/**
* 用户充值表分页列表
*/
@PostMapping("/getPageList")
@ApiOperation(value = "获取YxUserRecharge分页列表",notes = "用户充值表分页列表",response = YxUserRechargeQueryVo.class)
public ApiResult<Paging<YxUserRechargeQueryVo>> getYxUserRechargePageList(@Valid @RequestBody(required = false) YxUserRechargeQueryParam yxUserRechargeQueryParam) throws Exception{
Paging<YxUserRechargeQueryVo> paging = yxUserRechargeService.getYxUserRechargePageList(yxUserRechargeQueryParam);
return ApiResult.ok(paging);
}
}

View File

@ -0,0 +1,18 @@
<?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="co.yixiang.modules.activity.mapper.YxStoreSeckillMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, product_id, image, images, title, info, price, cost, ot_price, give_integral, sort, stock, sales, unit_name, postage, description, start_time, stop_time, add_time, status, is_postage, is_hot, is_del, num, is_show, end_time_date, start_time_date
</sql>
<select id="getYxStoreSeckillById" resultType="co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo">
select <include refid="Base_Column_List"/> from yx_store_seckill where id = #{id}
</select>
<select id="getYxStoreSeckillPageList" resultType="co.yixiang.modules.activity.web.vo.YxStoreSeckillQueryVo">
select <include refid="Base_Column_List"/> from yx_store_seckill
</select>
</mapper>