3564641c 刘嘉

菠萝派接口-订单下载

1 个父辈 1ba87f72
package com.sibu.orderHelper.integral.dao;
import com.sibu.orderHelper.integral.model.*;
import com.sibu.orderHelper.integral.pineapple.model.*;
import com.sibu.orderHelper.integral.pineapple.response.OrderResponse;
import com.sibu.orderHelper.integral.reponse.CheckRefundStatusResponse;
import com.sibu.orderHelper.integral.reponse.DoingOrderDetailResponse;
import com.sibu.orderHelper.integral.reponse.SkuApiResponse;
......@@ -74,7 +75,7 @@ public interface PineappleDao {
* @param params
* @return
*/
List<Orders> getOrdersList(Map<String,Object> params);
List<OrderResponse> getOrdersList(Map<String,Object> params);
/**
* 子订单查询
......
......@@ -37,9 +37,6 @@
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="regionName1" column="regionName1" />
<result property="regionName2" column="regionName2" />
<result property="regionName3" column="regionName3" />
</resultMap>
<!-- 根据订单号查询订单信息 只查询不是主订单的订单 -->
......@@ -159,9 +156,33 @@
UPDATE product SET product_stock = #{productStock} WHERE id = #{productId}
</update>
<!-- 下载订单实体-->
<resultMap id="orderResponse" type="com.sibu.orderHelper.integral.pineapple.response.OrderResponse">
<result property="platOrderNo" column="order_sn" />
<result property="tradeStatus" column="order_state" />
<result property="tradeStatusDescription" column="remark" />
<result property="tradeTime" column="create_time" />
<result property="province" column="regionName1" />
<result property="city" column="regionName2" />
<result property="area" column="regionName3" />
<result property="address" column="address_info" />
<result property="mobile" column="mobile" />
<result property="zip" column="zip_code" />
<result property="postFee" column="money_logistics" />
<result property="totalMoney" column="money_order" />
<result property="favourableMoney" column="couponMoney" />
<result property="goodsFee" column="money_product" />
<result property="payTime" column="pay_time" />
<result property="nick" column="member_name" />
</resultMap>
<!-- 主订单下载-->
<select id="getOrdersList" parameterType="java.util.Map" resultMap="orders">
select o.order_sn,o.order_state,o.remark,o.create_time,p.regionName AS regionName1,c.regionName AS regionName2,a.regionName AS regionName3,o.address_info,o.mobile,o.remark,o.zip_code,o.zip_code,
select o.order_sn,o.order_state,o.remark,o.create_time,p.regionName AS regionName1,
c.regionName AS regionName2,a.regionName AS regionName3,
o.address_info,o.mobile,o.zip_code,o.zip_code,o.money_logistics,o.money_product-o.money_order-o.money_logistics AS couponMoney
o.money_order,o.money_product,o.pay_time,o.member_name FROM orders o
LEFT JOIN regions p ON p.id = o.province_id
LEFT JOIN regions c ON c.id = o.city_id
......@@ -180,6 +201,7 @@
limit ${PageIndex}, ${PageSize}
</select>
<!-- 子订单实体-->
<resultMap id="ordersProduct" type="com.sibu.orderHelper.integral.pineapple.model.OrdersProduct">
<result property="id" column="id" />
<result property="ordersId" column="orders_id" />
......@@ -217,6 +239,19 @@
<result property="isEvaluate" column="is_evaluate" />
</resultMap>
<!-- 下载子订单实体-->
<!-- <resultMap id="ordersProduct" type="com.sibu.orderHelper.integral.pineapple.response.OrderGoodResponse">
<result property="productId" column="" />
<result property="subOrderNo" column="" />
<result property="tradeGoodsNo" column="" />
<result property="tradeGoodsName" column="" />
<result property="tradeGoodsSpec" column="" />
<result property="goodsCount" column="" />
<result property="price" column="" />
<result property="discountMoney" column="" />
<result property="status" column="" />
</resultMap>-->
<!-- 查询子订单-->
<select id="getOrdersProductList" resultType="java.util.Map" resultMap="ordersProduct">
......
......@@ -12,6 +12,7 @@ import com.sibu.orderHelper.integral.model.IMSupplier;
import com.sibu.orderHelper.integral.pineapple.constant.PineAppleConst;
import com.sibu.orderHelper.integral.pineapple.exception.BizException;
import com.sibu.orderHelper.integral.pineapple.model.Orders;
import com.sibu.orderHelper.integral.pineapple.model.OrdersProduct;
import com.sibu.orderHelper.integral.pineapple.request.CallRequest;
import com.sibu.orderHelper.integral.pineapple.request.GetOrderRequest;
......@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.xml.bind.ValidationException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -71,135 +73,40 @@ public class GetOrderBizServiceImpl extends AbstractBizService<GetOrderRequest>
}
params.put("PageIndex",(callRequest.getBizModel().getPageIndex() - 1) * callRequest.getBizModel().getPageSize());
params.put("PageSize",callRequest.getBizModel().getPageSize());
List<Orders> ordersList = pineappleDao.getOrdersList(params);
List<OrderResponse> ordersList = pineappleDao.getOrdersList(params);
GetOrderResponse response = new GetOrderResponse();
response.setNumTotalOrder(0);
response.setNumTotalOrder(ordersList.size());
response.setOrders(null);
response.setCode(PineAppleConst.SUCCESS_CODE);
return response;
}
@Override
public String getHandleMethodName() {
return "Differ.JH.Business.GetOrder";
}
/*
private GetOrderResponse findByOrderCode(CallRequest<GetOrderRequest> callRequest) {
DoingOrderDetailResponse order = null;
try {
order = iimDoingOrderService.getIMOrderDetailByOrderCode(callRequest.getBizModel().getPlatOrderNo());
if (order != null) {
this.getBarCode(order);
}
} catch (Exception e) {
log.error("获取订单数据业务异常", e);
throw new BizException("获取订单数据业务异常", e);
}
int numTotalOrder = 0;
private List<OrderResponse> findOrders(List<OrderResponse> ordersList){
List<OrderResponse> orders = new ArrayList<>();
if (order != null) {
numTotalOrder = 1;
orders.add(this.convertOrder(order));
if(!StringUtil.isNull(ordersList) && !ordersList.isEmpty()){
ordersList.stream().forEach(o ->{
OrderResponse orderResponse = new OrderResponse();
try {
pineappleDao.getOrdersProductList(o.getPayOrderNo());
if(StringUtil.isNull(null)){
throw new BizException(String.format("获取子订单数据业务异常[%s]",(o.getPayOrderNo())));
}
//orderResponse.setGoodInfos(orderProductList);
orders.add(orderResponse);
} catch (Exception e) {
log.error("获取订单数据业务异常", e);
throw new BizException("获取订单数据业务异常", e);
}
});
}
GetOrderResponse response = new GetOrderResponse();
response.setNumTotalOrder(numTotalOrder);
response.setOrders(orders);
response.setCode(PineAppleConst.SUCCESS_CODE);
return response;
}
private OrderResponse convertOrder(DoingOrderDetailResponse order) {
return this.platformOrderToPineAppleOrderConverter.convert(order);
return orders;
}
public DoingOrderDetailResponse getBarCode(DoingOrderDetailResponse source) throws Exception {
for (DoingOrder1DetailResponse entity:source.getOrder1s()){
IMProductBean product = pineappleDao.getIMProductBeanById(entity.getProductId());
if(StringUtil.isNotBlank(product.getBarCode())){
entity.setBarCode(product.getBarCode());
}
}
return source;
}
private BaseResponse findList(CallRequest<GetOrderRequest> callRequest) {
List<IMDoingOrderBean> list = new ArrayList<IMDoingOrderBean>();
//默认获取订单数量值
int[] modelValues = {0, 1, 2, 3, 4, 5, 6, 7};
String redisMysqlDbConfig = "";
Map<String, Object> params = new HashMap<>();
String orderTableName = "im_doing_order_";
String order1TableName = "im_doing_order1_";
List<String[]> tableNames = new ArrayList<String[]>();
//放入两个表名
for (int j = 0; j < DbUtil.TABLE_LASTCHAR1.size(); j++) {
tableNames.add(new String[]{orderTableName + DbUtil.TABLE_LASTCHAR1.get(j), order1TableName + DbUtil.TABLE_LASTCHAR1.get(j)});
}
params.put("tableNames", tableNames);
params.put("orderStatusList", callRequest.getBizModel().convertOrderStatus().getMallOrderStatus());
params.put("supplierId", callRequest.getSupplier().getId());
params.put("startTime", callRequest.getBizModel().convertAndCheckStartTime());
params.put("endTime", callRequest.getBizModel().convertAndCheckEndTime());
params.put("timeType", callRequest.getBizModel().convertTimeTypeEnum().getCode());
int pageStartInit = (callRequest.getBizModel().getPageIndex() - 1) * callRequest.getBizModel().getPageSize();
int pageSizeInt = callRequest.getBizModel().getPageSize();
int totalRecord = 0;
boolean queryFlag = true;
List<DoingOrderDetailResponse> orderBeans = new ArrayList<>();
//开始循环库查询
for (int i = 0; i < modelValues.length; i++) {
redisMysqlDbConfig = String.format(AppConstants.REDIS_DB_TYPE, AppConstants.INTEGRALMALL_ORDER_DATABASE, modelValues[i]);
DBContextHolder.setDBType(redisMysqlDbConfig);//切换数据源
int number = iMDoingOrderDao.countPineAppleOrder(params);
totalRecord += number;
if (queryFlag && number > 0) {
//已经查到有数据了,从下一张表的第一条记录开始查询
if (orderBeans != null && orderBeans.size() > 0) {
int pageSize = pageSizeInt - orderBeans.size();//减去已查到的数据
params.put("pageNow", 0);
params.put("pageSize", pageSize);
} else if (totalRecord > pageStartInit) {
int pageNow = pageStartInit - (totalRecord - number);
params.put("pageNow", pageNow);
params.put("pageSize", pageSizeInt);
} else {
continue;//继续循环
}
DBContextHolder.setDBType(redisMysqlDbConfig);//切换数据源
List<DoingOrderDetailResponse> orders = iMDoingOrderDao.pagerPineAppleOrders(params);
orderBeans.addAll(orders);
if (orderBeans.size() >= callRequest.getBizModel().getPageSize()) {
queryFlag = false;
}
}
}
List<OrderResponse> orders = orderBeans
.stream()
.map(p -> {
DoingOrderDetailResponse order = null;
try {
order = iimDoingOrderService.getIMOrderDetailByOrderCode(p.getOrderCode());
if(!StringUtil.isNull(order)){
this.getBarCode(order);
}
} catch (Exception e) {
log.error("获取订单数据业务异常", e);
throw new BizException("获取订单数据业务异常", e);
}
return order;
})
.map(p -> platformOrderToPineAppleOrderConverter.convert(p))
.collect(Collectors.toList());
GetOrderResponse response = new GetOrderResponse();
response.setNumTotalOrder(totalRecord);
response.setOrders(orders);
response.setCode(PineAppleConst.SUCCESS_CODE);
@Override
public String getHandleMethodName() {
return "Differ.JH.Business.GetOrder";
}
return response;
}*/
}
......