Authored by unknown

代码优化

... ... @@ -4,12 +4,14 @@ import org.apache.ibatis.annotations.Param;
import com.yoho.unions.dal.model.Orders;
import java.util.List;
public interface IOrdersMapper {
Orders selectByUidAndOrderCode(@Param("uid") int uid, @Param("orderCode") long orderCode);
Orders selectByOrderCode(@Param("orderCode") long orderCode);
List<Orders> selectByOrderCode(@Param("orderCode") long orderCode);
/**
* 查询某用户一段时间以来的已交寄订单
... ...
... ... @@ -15,6 +15,8 @@ public interface IUserOrdersDAO {
UserOrders selectByPrimaryKey(Integer id);
UserOrders selectByOrderCode(long orderCode);
int updateByPrimaryKeySelective(UserOrders record);
int updateByPrimaryKey(UserOrders record);
... ...
... ... @@ -43,7 +43,7 @@
select
<include refid="Base_Column_List"/>
from orders
where order_code = #{orderCode,jdbcType=BIGINT}
where parent_order_code = #{orderCode,jdbcType=BIGINT}
</select>
<select id="selectCountShipStatusOrderSince" resultType="java.lang.Integer">
... ...
... ... @@ -38,6 +38,12 @@
from user_orders
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_orders
where order_code = #{orderCode}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from user_orders
where id = #{id,jdbcType=INTEGER}
... ...
... ... @@ -83,53 +83,56 @@ public class UserOrdersServiceImpl implements IUserOrdersService,IBusinessExport
if(count>0){
userOrdersList = userOrdersDAO.selectUserOrderList(beginTime,endTime,String.valueOf(orderCode),unionId,idList,reqBO.getStart(),reqBO.getSize());
}
for(UserOrders userOrders:userOrdersList){
List<Orders> ordersList = new ArrayList<>();
for (UserOrders userOrders : userOrdersList) {
//根据查询出来的uid,ordercode,查询ERP_ORDERS.Orders
// Orders orders = ordersMapper.selectByUidAndOrderCode(userOrders.getuId(),Long.valueOf(userOrders.getOrderCode()));
Orders orders = ordersMapper.selectByOrderCode(Long.valueOf(userOrders.getOrderCode()));
List<Orders> order = ordersMapper.selectByOrderCode(Long.valueOf(userOrders.getOrderCode()));
ordersList.addAll(order);
}
for (Orders orders : ordersList) {
UnionOrderRspBO orderRspBO = new UnionOrderRspBO();
//优惠券金额
OrdersCoupons ordersCoupons = ordersCouponsMapper.selectByOrderCode(Long.valueOf(userOrders.getOrderCode()));
if(null!=ordersCoupons){
OrdersCoupons ordersCoupons = ordersCouponsMapper.selectByOrderCode(Long.valueOf(orders.getOrderCode()));
if (null != ordersCoupons) {
orderRspBO.setCouponAmount(ordersCoupons.getCouponAmount());
}else{
} else {
orderRspBO.setCouponAmount(new BigDecimal(0));
}
//防止订单数据没有在ERP中
if(null!=orders){
//订单金额
orderRspBO.setOrderAmount(orders.getOrderAmount());
orderRspBO.setYohoCoinNum(orders.getYohoCoinNum());
//运费
orderRspBO.setShipmentAmount(orders.getShippingCost());
//实际支付金额
orderRspBO.setRealPayAmount(orders.getLastOrderAmount().subtract(orders.getShippingCost()));
//订单状态
orderRspBO.setOrderStatus(OrderStatusEnum.getNameByCode(String.valueOf(orders.getOrderStatus())));
//附加信息
orderRspBO.setExetInfmoation(orders.getRemark());
//支付方式
orderRspBO.setPayChannel(PaymentTypeEnum.getNameByCode(String.valueOf(orders.getPaymentType())));
//是否新客---从新的表中获取
OrdersAccessOry ordersAccessOry = ordersAccessOryMapper.selectByPrimaryKey(Long.valueOf(userOrders.getOrderCode()));
if(null !=ordersAccessOry){
orderRspBO.setIsNew(NewUserEnum.getNameByCode(ordersAccessOry.getIsNew()==null?"N":ordersAccessOry.getIsNew()));
}else {
orderRspBO.setIsNew(NewUserEnum.getNameByCode("N"));
}
orderRspBO.setUid(orders.getUid());
//订单金额
orderRspBO.setOrderAmount(orders.getOrderAmount());
orderRspBO.setYohoCoinNum(orders.getYohoCoinNum());
//运费
orderRspBO.setShipmentAmount(orders.getShippingCost());
//实际支付金额
orderRspBO.setRealPayAmount(orders.getLastOrderAmount().subtract(orders.getShippingCost()));
//订单状态
orderRspBO.setOrderStatus(OrderStatusEnum.getNameByCode(String.valueOf(orders.getOrderStatus())));
//附加信息
orderRspBO.setExetInfmoation(orders.getRemark());
//支付方式
orderRspBO.setPayChannel(PaymentTypeEnum.getNameByCode(String.valueOf(orders.getPaymentType())));
//是否新客---从新的表中获取
OrdersAccessOry ordersAccessOry = ordersAccessOryMapper.selectByPrimaryKey(Long.valueOf(orders.getOrderCode()));
if (null != ordersAccessOry) {
orderRspBO.setIsNew(NewUserEnum.getNameByCode(ordersAccessOry.getIsNew() == null ? "N" : ordersAccessOry.getIsNew()));
} else {
orderRspBO.setIsNew(NewUserEnum.getNameByCode("N"));
}
orderRspBO.setOrderCode(Integer.valueOf(userOrders.getOrderCode()));
orderRspBO.setId(userOrders.getId());
orderRspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(userOrders.getCreateTime()) * Long.valueOf(1000), "yyyy-MM-dd"));
orderRspBO.setUnionId(userOrders.getUid());
MktMarketingUrl mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(userOrders.getUid()));
if(mktMarketingUrl!=null){
orderRspBO.setUnionType(mktMarketingUrl.getName());
orderRspBO.setUid(orders.getUid());
orderRspBO.setOrderCode(orders.getOrderCode().intValue());
orderRspBO.setId(orders.getId());
orderRspBO.setOrderTime(DateUtil.long2DateStr(Long.valueOf(orders.getCreateTime()) * Long.valueOf(1000), "yyyy-MM-dd"));
UserOrders userOrders = userOrdersDAO.selectByOrderCode(orders.getParentOrderCode());
if(userOrders!=null){
orderRspBO.setUnionId(userOrders.getUid());
MktMarketingUrl mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(userOrders.getUid()));
if (mktMarketingUrl != null) {
orderRspBO.setUnionType(mktMarketingUrl.getName());
}
}
unionOrderRspBOList.add(orderRspBO);
}
PageUnionOrderRspBO pageUnionOrderRspBO = new PageUnionOrderRspBO();
... ...