Merge branch 'master' of http://git.yoho.cn/ufo/yohoufo-fore
Showing
5 changed files
with
169 additions
and
0 deletions
1 | +package com.yohoufo.order.controller; | ||
2 | + | ||
3 | +import com.yohoufo.common.ApiResponse; | ||
4 | +import com.yohoufo.order.model.response.AssetsResp; | ||
5 | +import com.yohoufo.order.service.impl.AssetsService; | ||
6 | +import org.slf4j.Logger; | ||
7 | +import org.slf4j.LoggerFactory; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.stereotype.Controller; | ||
10 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
11 | +import org.springframework.web.bind.annotation.RequestParam; | ||
12 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
13 | + | ||
14 | +/** | ||
15 | + * Created by chenchao on 2018/9/28. | ||
16 | + */ | ||
17 | +@Controller | ||
18 | +public class AssetsController { | ||
19 | + | ||
20 | + final Logger logger = LoggerFactory.getLogger(getClass()); | ||
21 | + @Autowired | ||
22 | + private AssetsService assetsService; | ||
23 | + | ||
24 | + | ||
25 | + | ||
26 | + @RequestMapping(params = "method=ufo.asssets.details") | ||
27 | + @ResponseBody | ||
28 | + public ApiResponse getAssetsDetails(@RequestParam(name = "uid")int uid, | ||
29 | + @RequestParam(value = "page", required = false, defaultValue = "1") int page, | ||
30 | + @RequestParam(value = "limit", required = false, defaultValue = "10") int limit){ | ||
31 | + logger.info("in ufo.asssets.details, uid {},page {},limit {}", uid, page, limit); | ||
32 | + AssetsResp resp = assetsService.getAssetsDetails(uid, page, limit); | ||
33 | + return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("流水详情").build(); | ||
34 | + } | ||
35 | +} |
1 | +package com.yohoufo.order.model.bo; | ||
2 | + | ||
3 | +import lombok.AllArgsConstructor; | ||
4 | +import lombok.Data; | ||
5 | +import lombok.NoArgsConstructor; | ||
6 | +import lombok.experimental.Builder; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by chenchao on 2018/9/28. | ||
10 | + */ | ||
11 | +@Data | ||
12 | +@Builder | ||
13 | +@AllArgsConstructor | ||
14 | +@NoArgsConstructor | ||
15 | +public class TradeBillsBo { | ||
16 | + | ||
17 | + private int uid; | ||
18 | +} |
1 | +package com.yohoufo.order.model.bo; | ||
2 | + | ||
3 | +import lombok.AllArgsConstructor; | ||
4 | +import lombok.Data; | ||
5 | +import lombok.NoArgsConstructor; | ||
6 | +import lombok.experimental.Builder; | ||
7 | + | ||
8 | +import java.math.BigDecimal; | ||
9 | + | ||
10 | +/** | ||
11 | + * Created by chenchao on 2018/9/28. | ||
12 | + */ | ||
13 | +@Data | ||
14 | +@Builder | ||
15 | +@AllArgsConstructor | ||
16 | +@NoArgsConstructor | ||
17 | +public class TradeBillsSummaryBo { | ||
18 | + | ||
19 | + private String totalIncome; | ||
20 | + | ||
21 | + private transient BigDecimal total_income; | ||
22 | + /** | ||
23 | + * 货款 | ||
24 | + */ | ||
25 | + private String goodsIncome; | ||
26 | + | ||
27 | + private transient BigDecimal goods_income; | ||
28 | + /** | ||
29 | + *补偿款 | ||
30 | + */ | ||
31 | + private String compensateIncome; | ||
32 | + | ||
33 | + private transient BigDecimal compensate_income; | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | +} |
1 | +package com.yohoufo.order.model.response; | ||
2 | + | ||
3 | +import com.yohobuy.ufo.model.order.resp.PageResp; | ||
4 | +import com.yohoufo.order.model.bo.TradeBillsBo; | ||
5 | +import com.yohoufo.order.model.bo.TradeBillsSummaryBo; | ||
6 | +import lombok.Data; | ||
7 | + | ||
8 | +/** | ||
9 | + * Created by chenchao on 2018/9/28. | ||
10 | + */ | ||
11 | +@Data | ||
12 | +public class AssetsResp extends PageResp<TradeBillsBo>{ | ||
13 | + | ||
14 | + private TradeBillsSummaryBo summary; | ||
15 | + | ||
16 | +} |
1 | +package com.yohoufo.order.service.impl; | ||
2 | + | ||
3 | +import com.yohoufo.order.model.bo.TradeBillsBo; | ||
4 | +import com.yohoufo.order.model.bo.TradeBillsSummaryBo; | ||
5 | +import com.yohoufo.order.model.response.AssetsResp; | ||
6 | +import org.springframework.stereotype.Service; | ||
7 | + | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/**资产 | ||
11 | + * Created by chenchao on 2018/9/28. | ||
12 | + */ | ||
13 | +@Service | ||
14 | +public class AssetsService { | ||
15 | + | ||
16 | + | ||
17 | + public AssetsResp getAssetsDetails(int uid, int page, int pageSize){ | ||
18 | + | ||
19 | + //TODO get count | ||
20 | + int total = 0; | ||
21 | + | ||
22 | + TradeBillsSummaryBo summary = null; | ||
23 | + List<TradeBillsBo> detailList = null; | ||
24 | + if (total>0){ | ||
25 | + detailList = buildTradeBills(uid, page, pageSize); | ||
26 | + summary = buildTradeBillsSummary(uid); | ||
27 | + } | ||
28 | + | ||
29 | + | ||
30 | + AssetsResp assetsResp = new AssetsResp(); | ||
31 | + assetsResp.setSummary(summary); | ||
32 | + assetsResp.setData(detailList); | ||
33 | + assetsResp.setTotal(total); | ||
34 | + return assetsResp; | ||
35 | + } | ||
36 | + | ||
37 | + /** | ||
38 | + * TODO 可以考虑把第一页放缓存 | ||
39 | + * @param uid | ||
40 | + * @param page | ||
41 | + * @param pageSize | ||
42 | + * @return | ||
43 | + */ | ||
44 | + List<TradeBillsBo> buildTradeBills(int uid,int page, int pageSize){ | ||
45 | + List<TradeBillsBo> detailList = null; | ||
46 | + | ||
47 | + return detailList; | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * TODO 直接使用sql sum, 一定要缓存 | ||
52 | + * @param uid | ||
53 | + * @return | ||
54 | + */ | ||
55 | + TradeBillsSummaryBo buildTradeBillsSummary(int uid){ | ||
56 | + TradeBillsSummaryBo summary = null; | ||
57 | + //TODO 使用 sql sum 货款 | ||
58 | + //TODO 使用 sql sum 补偿款 | ||
59 | + | ||
60 | + //TODO 内存中计算total | ||
61 | + return summary; | ||
62 | + } | ||
63 | +} |
-
Please register or login to post a comment