gc-shop/src/main/java/com/xzx/gc/shop/controller/ApiGoodsController.java | ●●●●● patch | view | raw | blame | history | |
gc-shop/src/main/java/com/xzx/gc/shop/controller/ApiScoreController.java | ●●●●● patch | view | raw | blame | history | |
gc-shop/src/main/java/com/xzx/gc/shop/dto/XcxScoreDetailsDto.java | ●●●●● patch | view | raw | blame | history | |
gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreDetailsMapper.java | ●●●●● patch | view | raw | blame | history | |
gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java | ●●●●● patch | view | raw | blame | history | |
gc-shop/src/main/java/com/xzx/gc/shop/service/ScoreDetailsService.java | ●●●●● patch | view | raw | blame | history | |
gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxScoreDetailsVo.java | ●●●●● patch | view | raw | blame | history | |
gc-shop/src/main/resources/mapper/shop/ScoreDetailsMapper.xml | ●●●●● patch | view | raw | blame | history |
gc-shop/src/main/java/com/xzx/gc/shop/controller/ApiGoodsController.java
@@ -8,11 +8,14 @@ import com.xzx.gc.service.BaseAccountService; import com.xzx.gc.shop.dto.AddGoodsOrderDto; import com.xzx.gc.shop.dto.XcxGoodsListDto; import com.xzx.gc.shop.dto.XcxScoreDetailsDto; import com.xzx.gc.shop.service.GoodsService; import com.xzx.gc.shop.service.OrderService; import com.xzx.gc.shop.service.ScoreDetailsService; import com.xzx.gc.shop.vo.GoodsCategoryVo; import com.xzx.gc.shop.vo.XcxGoodsDetailVo; import com.xzx.gc.shop.vo.XcxGoodsListVo; import com.xzx.gc.shop.vo.XcxScoreDetailsVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; @@ -23,6 +26,7 @@ import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @RestController @Api(tags = {"积分商城--API商品管理"}) @@ -31,9 +35,6 @@ @Autowired private GoodsService goodsService; @Autowired private OrderService orderService; @ApiOperation("分类列表") @ApiResponses( gc-shop/src/main/java/com/xzx/gc/shop/controller/ApiScoreController.java
New file @@ -0,0 +1,38 @@ package com.xzx.gc.shop.controller; import com.xzx.gc.common.request.BaseController; import com.xzx.gc.model.JsonResult; import com.xzx.gc.shop.dto.XcxScoreDetailsDto; import com.xzx.gc.shop.service.ScoreDetailsService; import com.xzx.gc.shop.vo.XcxScoreDetailsVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; 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.RestController; import javax.servlet.http.HttpServletRequest; import java.util.Map; @RestController @Api(tags = {"积分商城--API积分管理"}) @Slf4j public class ApiScoreController extends BaseController { @Autowired private ScoreDetailsService scoreDetailsService; @ApiOperation("积分明细") @ApiResponses( @ApiResponse(code = 200, message = "success", response = XcxScoreDetailsVo.class) ) @PostMapping(value = "/score/details") public JsonResult<Map<String, Object>> scoreDetails(@RequestBody XcxScoreDetailsDto scoreDetailsDto, HttpServletRequest request) { scoreDetailsDto.setUserId(getUserId(request)); return JsonResult.success(scoreDetailsService.scoreDetails(scoreDetailsDto)); } } gc-shop/src/main/java/com/xzx/gc/shop/dto/XcxScoreDetailsDto.java
New file @@ -0,0 +1,19 @@ package com.xzx.gc.shop.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @ApiModel(value = "XcxScoreDetailsDto", description = "小程序积分明细参数接收类") public class XcxScoreDetailsDto { @ApiModelProperty(value="页码") private int pageNo=1; @ApiModelProperty(value="每页显示记录数") private int pageSize=10; @ApiModelProperty(hidden = true) private String userId; } gc-shop/src/main/java/com/xzx/gc/shop/mapper/ScoreDetailsMapper.java
@@ -2,7 +2,9 @@ import com.xzx.gc.entity.ScoreDetails; import com.xzx.gc.shop.dto.QueryScoreDetailsListDto; import com.xzx.gc.shop.dto.XcxScoreDetailsDto; import com.xzx.gc.shop.vo.QueryScoreDetailsListVo; import com.xzx.gc.shop.vo.XcxScoreDetailsVo; import com.xzx.gc.util.GcMapper; import org.apache.ibatis.annotations.Param; @@ -12,4 +14,5 @@ List<QueryScoreDetailsListVo> queryScoreDetailsList(@Param("record") QueryScoreDetailsListDto model); List<XcxScoreDetailsVo> selectXcxScoreDetailsList(@Param("record") XcxScoreDetailsDto xcxScoreDetailsDto); } gc-shop/src/main/java/com/xzx/gc/shop/service/OrderService.java
@@ -303,12 +303,25 @@ scoreOrderMapper.updateOrderStatus(id, ScoreOrder.STATUS_CANCEL, userId); // 退积分 AccountInfo accountInfo = accountInfoMapper.selectAccountInfoByUserId(userId); BigDecimal score = new BigDecimal(accountInfo.getCollectScore()).add(order.getTotalPrice()).setScale(0, BigDecimal.ROUND_DOWN); ScoreDetails scoreDetails = new ScoreDetails(); scoreDetails.setOriginalScore(new BigDecimal(accountInfo.getCollectScore())); scoreDetails.setCurrentScore(score); scoreDetails.setChangeScore(order.getTotalPrice()); scoreDetails.setOrderNo(order.getOrderNo()); scoreDetails.setType(ScoreDetails.SCORE_TYPE_SHOPPING_RETURN); scoreDetails.setCreatedTime(new Date()); scoreDetailsMapper.insert(scoreDetails); accountInfo.setCollectScore(score.toString()); accountInfoMapper.updateByPrimaryKey(accountInfo); // 减销量 加库存 List<ScoreOrderDetails> details = scoreOrderDetailsMapper.selectOrderDetailsByOrderId(order.getId()); if (CollUtil.isNotEmpty(details)) { gc-shop/src/main/java/com/xzx/gc/shop/service/ScoreDetailsService.java
@@ -5,11 +5,16 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.xzx.gc.common.utils.StringUtils; import com.xzx.gc.entity.AccountInfo; import com.xzx.gc.shop.dto.QueryScoreDetailsListDto; import com.xzx.gc.shop.dto.XcxScoreDetailsDto; import com.xzx.gc.shop.mapper.AccountInfoMapper; import com.xzx.gc.shop.mapper.ScoreDetailsMapper; import com.xzx.gc.shop.vo.QueryOrderListVo; import com.xzx.gc.shop.vo.QueryScoreDetailsListVo; import com.xzx.gc.shop.vo.XcxScoreDetailsVo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -25,6 +30,9 @@ @Resource ScoreDetailsMapper scoreDetailsMapper; @Autowired private AccountInfoMapper accountInfoMapper; public Map<String, Object> queryScoreDetailsList(QueryScoreDetailsListDto model) { PageHelper.startPage(model.getPage(), model.getLimit()); @@ -44,5 +52,16 @@ return map; } public Map<String, Object> scoreDetails(XcxScoreDetailsDto xcxScoreDetailsDto) { PageHelper.startPage(xcxScoreDetailsDto.getPageNo(), xcxScoreDetailsDto.getPageSize()); List<XcxScoreDetailsVo> details = scoreDetailsMapper.selectXcxScoreDetailsList(xcxScoreDetailsDto); AccountInfo accountInfo = accountInfoMapper.selectAccountInfoByUserId(xcxScoreDetailsDto.getUserId()); Map<String, Object> map = new HashMap<>(); map.put("score", accountInfo.getCollectScore()); map.put("data", details); return map; } } gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxScoreDetailsVo.java
New file @@ -0,0 +1,24 @@ 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.math.BigDecimal; import java.util.Date; @Data @ApiModel(value = "XcxScoreDetailsVo", description = "小程序积分明细返回参数类") public class XcxScoreDetailsVo { @ApiModelProperty(value = "类型 1-用户充值2-集物员支付3-用户兑换所得4-用户消费5-消费退回6-管理员充值7-其他") private Integer type; @ApiModelProperty(value = "时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date createdTime; @ApiModelProperty(value = "变动积分") private BigDecimal score; } gc-shop/src/main/resources/mapper/shop/ScoreDetailsMapper.xml
@@ -27,4 +27,12 @@ order by a.CREATED_TIME desc </select> <select id="selectXcxScoreDetailsList" resultType="com.xzx.gc.shop.vo.XcxScoreDetailsVo"> select * ,change_score score from xzx_score_details where user_id=#{record.userId} order by id desc </select> </mapper>