custom query

master
yixian 8 years ago
parent e11a5b4d92
commit b41a08e45a

@ -11,6 +11,8 @@ import au.com.royalpay.payment.tools.utils.PageListUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -25,6 +27,7 @@ import javax.annotation.Resource;
*/ */
@Service @Service
public class CustomServiceImpl implements CustomService { public class CustomServiceImpl implements CustomService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource @Resource
private CustomSupport customSupport; private CustomSupport customSupport;
@Resource @Resource
@ -36,12 +39,17 @@ public class CustomServiceImpl implements CustomService {
public JSONObject findOneWithDetail(String report_id) { public JSONObject findOneWithDetail(String report_id) {
JSONObject result = customReportsMapper.findOne(report_id); JSONObject result = customReportsMapper.findOne(report_id);
result.put("sub_orders", customReportDetailsMapper.findByReportId(report_id)); result.put("sub_orders", customReportDetailsMapper.findByReportId(report_id));
try {
result.put("query_result", customSupport.queryCustomResult(report_id));
} catch (Exception e) {
logger.error("Query Custom Declare status failure:", e);
}
return result; return result;
} }
@Override @Override
public void add(String orderId, String mchCustomId, String custom,String mchCustomName, List<JSONObject> subOrders) { public void add(String orderId, String mchCustomId, String custom, String mchCustomName, List<JSONObject> subOrders) {
CustomReport customReport = new CustomReport(orderId, mchCustomId, mchCustomName,custom); CustomReport customReport = new CustomReport(orderId, mchCustomId, mchCustomName, custom);
if (!CollectionUtils.isEmpty(subOrders)) { if (!CollectionUtils.isEmpty(subOrders)) {
subOrders.forEach(p -> { subOrders.forEach(p -> {
customReport.addSubOrder(p.getBigDecimal("order_fee"), p.getBigDecimal("order_fee").subtract(p.getBigDecimal("transport_fee"))); customReport.addSubOrder(p.getBigDecimal("order_fee"), p.getBigDecimal("order_fee").subtract(p.getBigDecimal("transport_fee")));
@ -68,11 +76,11 @@ public class CustomServiceImpl implements CustomService {
public JSONObject query(JSONObject param, int page, int limit) { public JSONObject query(JSONObject param, int page, int limit) {
param.put("orderStatus", OrderStatus.SUCCESS.getStatus()); param.put("orderStatus", OrderStatus.SUCCESS.getStatus());
List<String> channels = customSupport.customSupportedChannels(param.getIntValue("client_id")); List<String> channels = customSupport.customSupportedChannels(param.getIntValue("client_id"));
param.put("channels",channels); param.put("channels", channels);
if(!StringUtils.isEmpty(param.getString("channel"))) { if (!StringUtils.isEmpty(param.getString("channel"))) {
channels.clear(); channels.clear();
channels.add(param.getString("channel")); channels.add(param.getString("channel"));
param.put("channels",channels); param.put("channels", channels);
} }
return PageListUtils.buildPageListResult(customReportsMapper.queryWithTrans(param, new PageBounds(page, limit))); return PageListUtils.buildPageListResult(customReportsMapper.queryWithTrans(param, new PageBounds(page, limit)));
} }

Loading…
Cancel
Save