|
@@ -150,154 +150,144 @@ public class EfastOrderServiceImpl implements EfastOrderService {
|
|
|
@Override
|
|
|
public boolean addOrderInfoToEfast(MQMessage message) throws Exception {
|
|
|
logger.info("Watero addOrderInfoToEfast begin...");
|
|
|
- // orderInfo
|
|
|
- Order order = adminOrderService.getShopOrderByOrderId(message.getServiceToMessage());
|
|
|
- if (order == null || order.getSalesOrderid() == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ try {
|
|
|
+ // orderInfo
|
|
|
+ Order order = adminOrderService.getShopOrderByOrderId(message.getServiceToMessage());
|
|
|
+ if (order == null || order.getSalesOrderid() == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- List<OrderItem> items = adminOrderService.getShopOrderItemByOrderId(order.getSalesOrderid());
|
|
|
+ List<OrderItem> items = adminOrderService.getShopOrderItemByOrderId(order.getSalesOrderid());
|
|
|
|
|
|
- // request url
|
|
|
- //String url = NameUtils.getConfig("efast_base_url");
|
|
|
- String url = NameUtils.getConfig("rst_efast_base_url");
|
|
|
- // "http://test.iamberry.com//mallorder/order";
|
|
|
+ // request url
|
|
|
+ //String url = NameUtils.getConfig("efast_base_url");
|
|
|
+ String url = NameUtils.getConfig("rst_efast_base_url");
|
|
|
+ // "http://test.iamberry.com//mallorder/order";
|
|
|
|
|
|
- // set Requeset Data
|
|
|
- Map<String, String> requestData = new HashMap<String, String>();
|
|
|
+ // set Requeset Data
|
|
|
+ Map<String, String> requestData = new HashMap<String, String>();
|
|
|
+
|
|
|
+ int money = order.getSalesYetAmount();
|
|
|
|
|
|
- int money = order.getSalesYetAmount();
|
|
|
-
|
|
|
- double couponMoney = 0;
|
|
|
- double avgPercentage = 0.0; //均摊比例
|
|
|
- //将优惠券抵消金额加入实付金额中
|
|
|
- if (order.getCouponId() != null && !"".equals(order.getCouponId())) {
|
|
|
- CouponItem couponItem = new CouponItem();
|
|
|
- couponItem.setCouponItemId(order.getCouponId());
|
|
|
- couponItem.setCouponItemUseropenid(order.getSalesOpenid());
|
|
|
- CouponType couponType = cartService.getCouponReduceByItemId(couponItem);
|
|
|
- if (null != couponType) {
|
|
|
- switch (couponType.getCouponType()) {
|
|
|
- case 1:
|
|
|
- couponMoney = couponType.getCouponReduce();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- couponMoney = order.getSalesAmount() * couponType.getCouponReduce();
|
|
|
- break;
|
|
|
+ double couponMoney = 0;
|
|
|
+ double avgPercentage = 0.0; //均摊比例
|
|
|
+ //将优惠券抵消金额加入实付金额中
|
|
|
+ if (order.getCouponId() != null && !"".equals(order.getCouponId())) {
|
|
|
+ CouponItem couponItem = new CouponItem();
|
|
|
+ couponItem.setCouponItemId(order.getCouponId());
|
|
|
+ couponItem.setCouponItemUseropenid(order.getSalesOpenid());
|
|
|
+ CouponType couponType = cartService.getCouponReduceByItemId(couponItem);
|
|
|
+ if (null != couponType) {
|
|
|
+ switch (couponType.getCouponType()) {
|
|
|
+ case 1:
|
|
|
+ couponMoney = couponType.getCouponReduce();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ couponMoney = order.getSalesAmount() * couponType.getCouponReduce();
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //只计算用户用微信支付的金额,不包含余额支付
|
|
|
- if (order.getBalancePayAmount() != null && !"".equals(order.getBalancePayAmount().toString())) {
|
|
|
- money = money - order.getBalancePayAmount().intValue();
|
|
|
- couponMoney += order.getBalancePayAmount().intValue();
|
|
|
- }
|
|
|
- //计算分摊金额比例
|
|
|
- if (items != null && items.size() > 0) {
|
|
|
- double avgMoney = 0;
|
|
|
- for (OrderItem item : items) {
|
|
|
- avgMoney += item.getItemNum().intValue() * item.getItemProductDiscount();
|
|
|
+ //只计算用户用微信支付的金额,不包含余额支付
|
|
|
+ if (order.getBalancePayAmount() != null && !"".equals(order.getBalancePayAmount().toString())) {
|
|
|
+ money = money - order.getBalancePayAmount().intValue();
|
|
|
+ couponMoney += order.getBalancePayAmount().intValue();
|
|
|
}
|
|
|
- //计算均摊比例
|
|
|
- avgPercentage = 1 - couponMoney / avgMoney;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 系统级参数
|
|
|
- */
|
|
|
- /*requestData.put("app_nick", NameUtils.getConfig("app_nick"));
|
|
|
- requestData.put("app_key", NameUtils.getConfig("app_key"));
|
|
|
- requestData.put("app_secret", NameUtils.getConfig("app_secret"));
|
|
|
- requestData.put("timestamp",DateTimeUtil.format(new Date(),"yyyyMMddHHmmss"));
|
|
|
- requestData.put("app_act", message.getServiceOtherMessage());*/ // "efast.trade.new.add"
|
|
|
- requestData.put("app_act", "rst.trade.new.add");
|
|
|
-
|
|
|
- /**
|
|
|
- * 订单基本信息
|
|
|
- */
|
|
|
- String[] addressDesc = order.getSalesAddressInfo().split("-");
|
|
|
-
|
|
|
- //判断收货地址从而选择仓库
|
|
|
- String sd_id = NameUtils.getConfig("sd_id");
|
|
|
-
|
|
|
- String address = addressDesc[3];
|
|
|
- if (addressDesc[3] != null) {
|
|
|
- Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
|
|
- Matcher m = p.matcher(addressDesc[3]);
|
|
|
- if (m.find()) {
|
|
|
- address = m.replaceAll("");
|
|
|
+ //计算分摊金额比例
|
|
|
+ if (items != null && items.size() > 0) {
|
|
|
+ double avgMoney = 0;
|
|
|
+ for (OrderItem item : items) {
|
|
|
+ avgMoney += item.getItemNum().intValue() * item.getItemProductDiscount();
|
|
|
+ }
|
|
|
+ //计算均摊比例
|
|
|
+ avgPercentage = 1 - couponMoney / avgMoney;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- String provinceName = addressDesc[0];
|
|
|
- if (addressDesc[0].indexOf("北京") != -1) {
|
|
|
- provinceName = "北京";
|
|
|
- } else if (addressDesc[0].indexOf("上海") != -1) {
|
|
|
- provinceName = "上海";
|
|
|
- } else if (addressDesc[0].indexOf("天津") != -1) {
|
|
|
- provinceName = "天津";
|
|
|
- } else if (addressDesc[0].indexOf("重庆") != -1) {
|
|
|
- provinceName = "重庆";
|
|
|
- }
|
|
|
- Map<String, Object> orderData = new HashMap<String, Object>();
|
|
|
- orderData.put("add_time", DateTimeUtil.format(order.getSalesCreateDate())); // 时间
|
|
|
- orderData.put("address", address); // 收货地址
|
|
|
- orderData.put("city_name", addressDesc[1]); // 城市
|
|
|
- orderData.put("consignee", order.getSalesAddressName()); // 收货人
|
|
|
- orderData.put("district_name", addressDesc[2]); // 区域
|
|
|
- orderData.put("postalcode", order.getSalesAddressPostnum()); // salesAddressPostnum
|
|
|
- orderData.put("email", ""); // email
|
|
|
- orderData.put("goods_amount", (order.getSalesAmount())); // 商品总价
|
|
|
- orderData.put("goods_count", items.size()); // 产品数量
|
|
|
- orderData.put("mobile", order.getSalesAddressTel()); // 手机号码
|
|
|
- orderData.put("money_paid", money); // 已付款
|
|
|
- orderData.put("oid", order.getSalesOrderid()); // 订单号
|
|
|
- orderData.put("order_amount", money); // 应付款,应付款金额要与已付款金额相同
|
|
|
|
|
|
+ requestData.put("app_act", "rst.trade.new.add");
|
|
|
|
|
|
- /**
|
|
|
- * 产品信息
|
|
|
- */
|
|
|
- List<Map<String, Object>> maps = new ArrayList<Map<String, Object>>();
|
|
|
- for (OrderItem item : items) {
|
|
|
- Map<String, Object> orders1 = new HashMap<String, Object>();
|
|
|
- orders1.put("goods_name", item.getItemProductName()); // 产品名称
|
|
|
- orders1.put("goods_number", item.getItemNum()); // 产品数量
|
|
|
- orders1.put("goods_price", (item.getItemProductPrice())); // 产品原价
|
|
|
- orders1.put("outer_sku", item.getProduectRemark()); // 产品SKU
|
|
|
- orders1.put("payment_ft", (item.getItemProductDiscount() * avgPercentage * item.getItemNum())); // 产品分摊价
|
|
|
- maps.add(orders1);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 订单基本信息
|
|
|
+ */
|
|
|
+ String[] addressDesc = order.getSalesAddressInfo().split("-");
|
|
|
|
|
|
- orderData.put("orders", maps); // 订单产品
|
|
|
- orderData.put("pay_name", "weixinpay"); // 支付方式
|
|
|
- orderData.put("pay_time", DateTimeUtil.format(order.getSalesTransactionDate()));// 支付时间
|
|
|
- orderData.put("postscript", order.getSalesUserRemark()); // 买家留言
|
|
|
- orderData.put("province_name", provinceName); // 省份
|
|
|
- orderData.put("sd_id", sd_id); // 对应 efast 店铺 id
|
|
|
- orderData.put("shipping_fee", 0); // 快递费
|
|
|
- orderData.put("shipping_name", "yto"); // 快递公司代码
|
|
|
- orderData.put("tel", order.getSalesAddressTel()); // 我司电话
|
|
|
- orderData.put("to_buyer", ""); // 商家备注
|
|
|
- //orderData.put("total_amount", (order.getSalesAmount()/100.0)); // 订单总额
|
|
|
- orderData.put("total_amount", (order.getSalesAmount())); // 订单总额
|
|
|
- orderData.put("user_name", order.getSalesOpenid()); // 买家账户 百胜根据user_name来判断是否有重复,传openId是为了防止重复
|
|
|
- orderData.put("zipcode", order.getSalesAddressPostnum()); // 邮编
|
|
|
+ //判断收货地址从而选择仓库
|
|
|
+ String sd_id = NameUtils.getConfig("sd_id");
|
|
|
|
|
|
+ String address = addressDesc[3];
|
|
|
+ if (addressDesc[3] != null) {
|
|
|
+ Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
|
|
+ Matcher m = p.matcher(addressDesc[3]);
|
|
|
+ if (m.find()) {
|
|
|
+ address = m.replaceAll("");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- com.fasterxml.jackson.databind.ObjectMapper mapper = new ObjectMapper();
|
|
|
- String orderDataStr = null;
|
|
|
- ;
|
|
|
- try {
|
|
|
- orderDataStr = mapper.writeValueAsString(orderData);
|
|
|
- } catch (JsonProcessingException e2) {
|
|
|
- e2.printStackTrace();
|
|
|
- }
|
|
|
+ String provinceName = addressDesc[0];
|
|
|
+ if (addressDesc[0].indexOf("北京") != -1) {
|
|
|
+ provinceName = "北京";
|
|
|
+ } else if (addressDesc[0].indexOf("上海") != -1) {
|
|
|
+ provinceName = "上海";
|
|
|
+ } else if (addressDesc[0].indexOf("天津") != -1) {
|
|
|
+ provinceName = "天津";
|
|
|
+ } else if (addressDesc[0].indexOf("重庆") != -1) {
|
|
|
+ provinceName = "重庆";
|
|
|
+ }
|
|
|
+ Map<String, Object> orderData = new HashMap<String, Object>();
|
|
|
+ orderData.put("add_time", DateTimeUtil.format(order.getSalesCreateDate())); // 时间
|
|
|
+ orderData.put("address", address); // 收货地址
|
|
|
+ orderData.put("city_name", addressDesc[1]); // 城市
|
|
|
+ orderData.put("consignee", order.getSalesAddressName()); // 收货人
|
|
|
+ orderData.put("district_name", addressDesc[2]); // 区域
|
|
|
+ orderData.put("postalcode", order.getSalesAddressPostnum()); // salesAddressPostnum
|
|
|
+ orderData.put("email", ""); // email
|
|
|
+ orderData.put("goods_amount", (order.getSalesAmount())); // 商品总价
|
|
|
+ orderData.put("goods_count", items.size()); // 产品数量
|
|
|
+ orderData.put("mobile", order.getSalesAddressTel()); // 手机号码
|
|
|
+ orderData.put("money_paid", money); // 已付款
|
|
|
+ orderData.put("oid", order.getSalesOrderid()); // 订单号
|
|
|
+ orderData.put("order_amount", money); // 应付款,应付款金额要与已付款金额相同
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产品信息
|
|
|
+ */
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<Map<String, Object>>();
|
|
|
+ for (OrderItem item : items) {
|
|
|
+ Map<String, Object> orders1 = new HashMap<String, Object>();
|
|
|
+ orders1.put("goods_name", item.getItemProductName()); // 产品名称
|
|
|
+ orders1.put("goods_number", item.getItemNum()); // 产品数量
|
|
|
+ orders1.put("goods_price", (item.getItemProductPrice())); // 产品原价
|
|
|
+ orders1.put("outer_sku", item.getProduectRemark()); // 产品SKU
|
|
|
+ orders1.put("payment_ft", (item.getItemProductDiscount() * avgPercentage * item.getItemNum())); // 产品分摊价
|
|
|
+ maps.add(orders1);
|
|
|
+ }
|
|
|
|
|
|
- requestData.put("info", orderDataStr);
|
|
|
+ orderData.put("orders", maps); // 订单产品
|
|
|
+ orderData.put("pay_name", "weixinpay"); // 支付方式
|
|
|
+ orderData.put("pay_time", DateTimeUtil.format(order.getSalesTransactionDate()));// 支付时间
|
|
|
+ orderData.put("postscript", order.getSalesUserRemark()); // 买家留言
|
|
|
+ orderData.put("province_name", provinceName); // 省份
|
|
|
+ orderData.put("sd_id", sd_id); // 对应 efast 店铺 id
|
|
|
+ orderData.put("shipping_fee", 0); // 快递费
|
|
|
+ orderData.put("shipping_name", "yto"); // 快递公司代码
|
|
|
+ orderData.put("tel", order.getSalesAddressTel()); // 我司电话
|
|
|
+ orderData.put("to_buyer", ""); // 商家备注
|
|
|
+ //orderData.put("total_amount", (order.getSalesAmount()/100.0)); // 订单总额
|
|
|
+ orderData.put("total_amount", (order.getSalesAmount())); // 订单总额
|
|
|
+ orderData.put("user_name", order.getSalesOpenid()); // 买家账户 百胜根据user_name来判断是否有重复,传openId是为了防止重复
|
|
|
+ orderData.put("zipcode", order.getSalesAddressPostnum()); // 邮编
|
|
|
+
|
|
|
+
|
|
|
+ com.fasterxml.jackson.databind.ObjectMapper mapper = new ObjectMapper();
|
|
|
+ String orderDataStr = null;
|
|
|
+ try {
|
|
|
+ orderDataStr = mapper.writeValueAsString(orderData);
|
|
|
+ } catch (JsonProcessingException e2) {
|
|
|
+ e2.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
+ requestData.put("info", orderDataStr);
|
|
|
logger.info("Water HttpClient431Util.doGet begin..."+url+"requestData..="+requestData.get("info")+"accpt="+requestData.get("app_act"));
|
|
|
String result = HttpClient431Util.doPost(requestData, url);
|
|
|
result = StringEscapeUtils.unescapeJava(result); // unicode 编码
|
|
@@ -312,18 +302,15 @@ public class EfastOrderServiceImpl implements EfastOrderService {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
- logger.error(this, "watero add-推送订单号为:" + order.getSalesOrderid() + "的订单,百胜返回信息:" + result);
|
|
|
+ logger.error(this, "watero add-推送订单号为:" + order.getSalesOrderid() + "的订单,RST返回信息:" + result);
|
|
|
throw new Exception(jsonObject.getString("msg"));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
logger.info(this, "Watero addOrderInfoToEfast error..");
|
|
|
}
|
|
|
+ logger.info(this, "Watero addOrderInfoToEfast end..");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public boolean addProbationOrderToEfast(MQMessage message) throws Exception {
|