Authored by sailing-PC\sailing

add frame

package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.model.response.AssetsResp;
import com.yohoufo.order.service.impl.AssetsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Created by chenchao on 2018/9/28.
*/
@Controller
public class AssetsController {
final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AssetsService assetsService;
@RequestMapping(params = "method=ufo.asssets.details")
@ResponseBody
public ApiResponse getAssetsDetails(@RequestParam(name = "uid")int uid,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit){
logger.info("in ufo.asssets.details, uid {},page {},limit {}", uid, page, limit);
AssetsResp resp = assetsService.getAssetsDetails(uid, page, limit);
return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("流水详情").build();
}
}
... ...
package com.yohoufo.order.model.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by chenchao on 2018/9/28.
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TradeBillsBo {
private int uid;
}
... ...
package com.yohoufo.order.model.bo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import java.math.BigDecimal;
/**
* Created by chenchao on 2018/9/28.
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TradeBillsSummaryBo {
private String totalIncome;
private transient BigDecimal total_income;
/**
* 货款
*/
private String goodsIncome;
private transient BigDecimal goods_income;
/**
*补偿款
*/
private String compensateIncome;
private transient BigDecimal compensate_income;
}
... ...
package com.yohoufo.order.model.response;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.order.model.bo.TradeBillsBo;
import com.yohoufo.order.model.bo.TradeBillsSummaryBo;
import lombok.Data;
/**
* Created by chenchao on 2018/9/28.
*/
@Data
public class AssetsResp extends PageResp<TradeBillsBo>{
private TradeBillsSummaryBo summary;
}
... ...
package com.yohoufo.order.service.impl;
import com.yohoufo.order.model.bo.TradeBillsBo;
import com.yohoufo.order.model.bo.TradeBillsSummaryBo;
import com.yohoufo.order.model.response.AssetsResp;
import org.springframework.stereotype.Service;
import java.util.List;
/**资产
* Created by chenchao on 2018/9/28.
*/
@Service
public class AssetsService {
public AssetsResp getAssetsDetails(int uid, int page, int pageSize){
//TODO get count
int total = 0;
TradeBillsSummaryBo summary = null;
List<TradeBillsBo> detailList = null;
if (total>0){
detailList = buildTradeBills(uid, page, pageSize);
summary = buildTradeBillsSummary(uid);
}
AssetsResp assetsResp = new AssetsResp();
assetsResp.setSummary(summary);
assetsResp.setData(detailList);
assetsResp.setTotal(total);
return assetsResp;
}
/**
* TODO 可以考虑把第一页放缓存
* @param uid
* @param page
* @param pageSize
* @return
*/
List<TradeBillsBo> buildTradeBills(int uid,int page, int pageSize){
List<TradeBillsBo> detailList = null;
return detailList;
}
/**
* TODO 直接使用sql sum, 一定要缓存
* @param uid
* @return
*/
TradeBillsSummaryBo buildTradeBillsSummary(int uid){
TradeBillsSummaryBo summary = null;
//TODO 使用 sql sum 货款
//TODO 使用 sql sum 补偿款
//TODO 内存中计算total
return summary;
}
}
... ...