...
|
...
|
@@ -5,12 +5,15 @@ import com.netflix.config.DynamicBooleanProperty; |
|
|
import com.netflix.config.DynamicPropertyFactory;
|
|
|
import com.netflix.config.DynamicStringProperty;
|
|
|
import com.yoho.unions.common.utils.HttpUtils;
|
|
|
import com.yoho.unions.dal.IUnionOrderPushDAO;
|
|
|
import com.yoho.unions.dal.model.UnionOrderPush;
|
|
|
import com.yoho.unions.server.service.IOrderPushService;
|
|
|
import com.yoho.unions.vo.OrderInfo;
|
|
|
import com.yoho.unions.vo.OrdersGood;
|
|
|
import net.spy.memcached.compat.log.Logger;
|
|
|
import net.spy.memcached.compat.log.LoggerFactory;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
...
|
...
|
@@ -25,6 +28,9 @@ import java.util.Map; |
|
|
@Service
|
|
|
public class OrderPushServiceImpl implements IOrderPushService{
|
|
|
|
|
|
@Autowired
|
|
|
IUnionOrderPushDAO unionOrderPushDAO;
|
|
|
|
|
|
static final Logger logger = LoggerFactory.getLogger(OrderPushServiceImpl.class);
|
|
|
//推送公共的订单
|
|
|
public void pushOrder(List<OrderInfo> orderInfos){
|
...
|
...
|
@@ -61,7 +67,9 @@ public class OrderPushServiceImpl implements IOrderPushService{ |
|
|
//商品名称
|
|
|
param.put("proName", good.getProductName());
|
|
|
//商品分类名称
|
|
|
param.put("proCat", good.getSortName());
|
|
|
param.put("proSortName", good.getSortName());
|
|
|
//商品分类id
|
|
|
param.put("proSortId",good.getSortId());
|
|
|
//商品最终支付金额
|
|
|
proRealPay = good.getRealPayFee().setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
} else {
|
...
|
...
|
@@ -70,28 +78,38 @@ public class OrderPushServiceImpl implements IOrderPushService{ |
|
|
StringBuffer nums = new StringBuffer();
|
|
|
StringBuffer names = new StringBuffer();
|
|
|
StringBuffer cats = new StringBuffer();
|
|
|
StringBuffer sortIds = new StringBuffer();
|
|
|
for (int i = 0; i < goods.size(); i++) {
|
|
|
skns.append(goods.get(i).getProductSkn() + "|");
|
|
|
prices.append(goods.get(i).getLastPrice().setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + "|");
|
|
|
nums.append(goods.get(i).getBuyNumber() + "|");
|
|
|
names.append(goods.get(i).getProductName() + "|");
|
|
|
cats.append(goods.get(i).getSortName() + "|");
|
|
|
sortIds.append(goods.get(i).getSortId()+"|");
|
|
|
proRealPay = proRealPay.add(goods.get(i).getRealPayFee());
|
|
|
|
|
|
}
|
|
|
param.put("proNo", skns.substring(0, skns.length() - 1));
|
|
|
param.put("proPrice", prices.substring(0, prices.length() - 1));
|
|
|
param.put("proNum", nums.substring(0, nums.length() - 1));
|
|
|
param.put("proName", names.substring(0, names.length() - 1));
|
|
|
param.put("proCat", cats.substring(0, cats.length() - 1));
|
|
|
param.put("proSortName", cats.substring(0, cats.length() - 1));
|
|
|
param.put("proSortId", sortIds.substring(0, cats.length() - 1));
|
|
|
}
|
|
|
param.put("proRealPay",proRealPay.doubleValue());
|
|
|
//渠道id
|
|
|
param.put("channelId",orderInfo.getClientId());
|
|
|
//佣金比例---根据不同的厂商去计算,在表中维护
|
|
|
//根据不同的厂商,发送不同的URL
|
|
|
int clientId = orderInfo.getClientId();
|
|
|
UnionOrderPush unionOrderPush = unionOrderPushDAO.selectByChannelId(clientId);
|
|
|
String commRate = unionOrderPush.getCommRate();
|
|
|
param.put("commRate", commRate == null?0:commRate);
|
|
|
Pair<Integer, String> pair = null;
|
|
|
try {
|
|
|
//根据不同的厂商,发送不同的URL
|
|
|
int clientId = orderInfo.getClientId();
|
|
|
DynamicStringProperty url = DynamicPropertyFactory.getInstance().getStringProperty("union-type-url:"+clientId, "");
|
|
|
String url = unionOrderPush.getUrl();
|
|
|
logger.info("pushOrder: url is {}, param is {}", url, param);
|
|
|
pair = HttpUtils.httpPost(url.get(), param);
|
|
|
pair = HttpUtils.httpPost(url, param);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("common order post fail,orderCode is {}", orderInfo.getParentOrderCode());
|
|
|
}
|
...
|
...
|
|