1 files added
6 files modified
| | |
| | | import com.xzx.gc.shop.dto.AddGoodsOrderDto; |
| | | import com.xzx.gc.shop.dto.XcxOrderListDto; |
| | | import com.xzx.gc.shop.service.OrderService; |
| | | import com.xzx.gc.shop.vo.StatisticsVo; |
| | | import com.xzx.gc.shop.vo.XcxOrderDetailsVo; |
| | | import com.xzx.gc.shop.vo.XcxOrderListVo; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import io.swagger.annotations.ApiResponses; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation("首页统计") |
| | | @GetMapping(value = "/order/statistics") |
| | | public JsonResult<StatisticsVo> orderStatistics(HttpServletRequest request) { |
| | | return JsonResult.success(orderService.orderStatistics(getUserId(request))); |
| | | } |
| | | } |
| | |
| | | import com.xzx.gc.util.GcMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | public interface ScoreDetailsMapper extends GcMapper<ScoreDetails> { |
| | |
| | | List<QueryScoreDetailsListVo> queryScoreDetailsList(@Param("record") QueryScoreDetailsListDto model); |
| | | |
| | | List<XcxScoreDetailsVo> selectXcxScoreDetailsList(@Param("record") XcxScoreDetailsDto xcxScoreDetailsDto); |
| | | |
| | | BigDecimal selectTotalScoreByUserId(@Param("userId") String userId, @Param("type") Integer type); |
| | | } |
| | |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface ScoreOrderMapper extends GcMapper<ScoreOrder> { |
| | | |
| | |
| | | XcxOrderDetailsVo selectXcxOrderDetails(@Param("id") Long id); |
| | | |
| | | int updateOrderStatus(@Param("id") Long id, @Param("status") Integer status, @Param("userId") String userId); |
| | | |
| | | Map<String, Object> selectOrderStastics(@Param("userId") String userId); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | public StatisticsVo orderStatistics(String userId) { |
| | | BigDecimal score = scoreDetailsMapper.selectTotalScoreByUserId(userId, ScoreDetails.SCORE_TYPE_EXCHANGE); |
| | | |
| | | Map<String, Object> userData = scoreOrderMapper.selectOrderStastics(userId); |
| | | Map<String, Object> allData = scoreOrderMapper.selectOrderStastics(null); |
| | | |
| | | StatisticsVo statisticsVo = new StatisticsVo(); |
| | | statisticsVo.setScore(score); |
| | | BigDecimal userPrice = (BigDecimal) userData.get("totalPrice"); |
| | | statisticsVo.setReduceCarbon(userPrice.divide(BigDecimal.TEN, 2, BigDecimal.ROUND_DOWN)); |
| | | statisticsVo.setOrderCnt(Integer.parseInt(userData.get("totalOrder").toString())); |
| | | |
| | | BigDecimal totalPrice = (BigDecimal) allData.get("totalPrice"); |
| | | statisticsVo.setTotalReduceCarbon(totalPrice.divide(BigDecimal.TEN, 2, BigDecimal.ROUND_DOWN)); |
| | | statisticsVo.setTotalOrderCnt(Integer.parseInt(allData.get("totalOrder").toString())); |
| | | statisticsVo.setTotalBuyCnt(Integer.parseInt(allData.get("totalBuy").toString())); |
| | | return statisticsVo; |
| | | } |
| | | } |
New file |
| | |
| | | package com.xzx.gc.shop.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Data |
| | | @ApiModel(value = "StatisticsVo", description = "统计") |
| | | public class StatisticsVo { |
| | | |
| | | @ApiModelProperty(value = "个人参与次数") |
| | | private Integer orderCnt; |
| | | |
| | | @ApiModelProperty(value = "获得积分") |
| | | private BigDecimal score; |
| | | |
| | | @ApiModelProperty(value = "减少碳排放量") |
| | | private BigDecimal reduceCarbon; |
| | | |
| | | @ApiModelProperty(value = "用户参与次数") |
| | | private Integer totalOrderCnt; |
| | | |
| | | @ApiModelProperty(value = "积分兑换次数") |
| | | private Integer totalBuyCnt; |
| | | |
| | | @ApiModelProperty(value = "总减少排放量") |
| | | private BigDecimal totalReduceCarbon; |
| | | } |
| | |
| | | where user_id=#{record.userId} |
| | | order by id desc |
| | | </select> |
| | | |
| | | <select id="selectTotalScoreByUserId" resultType="java.math.BigDecimal"> |
| | | select sum(change_score) |
| | | from xzx_score_details |
| | | where user_id=#{userId} and type=#{type} |
| | | </select> |
| | | </mapper> |
| | |
| | | set status=#{status} |
| | | where id=#{id} and user_id=#{userId} |
| | | </update> |
| | | |
| | | <select id="selectOrderStastics" resultType="java.util.Map"> |
| | | select |
| | | IFNULL(count(1), 0) totalBuy, |
| | | IFNULL(sum(IFNULL(total_price,0)),0) totalPrice, |
| | | ( |
| | | select IFNULL(count(1),0) from xzx_jhy_order where status = 3 |
| | | <if test="userId != null and userId != ''"> |
| | | and user_id=#{userId} |
| | | </if> |
| | | ) totalOrder |
| | | from xzx_score_order |
| | | where status=3 |
| | | <if test="userId != null and userId != ''"> |
| | | and user_id=#{userId} |
| | | </if> |
| | | </select> |
| | | </mapper> |