|
@@ -6,7 +6,21 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Random;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.iamberry.wechat.core.entity.coupon.CouponItem;
|
|
|
+import com.iamberry.wechat.core.entity.coupon.CouponType;
|
|
|
+import com.iamberry.wechat.core.entity.mq.MQMessage;
|
|
|
+import com.iamberry.wechat.core.entity.order.OrderItem;
|
|
|
+import com.iamberry.wechat.face.porduct.ProductColorService;
|
|
|
+import com.iamberry.wechat.tools.DateTimeUtil;
|
|
|
+import com.iamberry.wechat.tools.HttpClient431Util;
|
|
|
+import com.iamberry.wechat.tools.NameUtils;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -93,14 +107,121 @@ public class GiftCardServiceImpl implements GiftCardService {
|
|
|
if (agentMapper.updateAgentCardSum(agentInfo) <= 0) {
|
|
|
throw new RuntimeException();
|
|
|
}
|
|
|
-
|
|
|
- // 推送百胜
|
|
|
+
|
|
|
+ //推送到rst
|
|
|
+ String url = NameUtils.getConfig("rst_efast_base_url");
|
|
|
+ Map<String, String> requestData = new HashMap<String, String>();
|
|
|
+ /**
|
|
|
+ * 系统级参数
|
|
|
+ */
|
|
|
+ requestData.put("app_act", "rst.trade.new.add");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单基本信息
|
|
|
+ */
|
|
|
+ String[] addressDesc = machineInfo.getUserMachineAddressInfo().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("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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 = "重庆";
|
|
|
+ }
|
|
|
+ //颜色表查询
|
|
|
+ ProductColor productColor = colorMapper.selectProductColorById(machineInfo.getUserMachineColorId());
|
|
|
+ Map<String, Object> orderData = new HashMap<String, Object>();
|
|
|
+ orderData.put("add_time", DateTimeUtil.format(new Date())); // 时间
|
|
|
+ orderData.put("address", address); // 收货地址
|
|
|
+ orderData.put("city_name", addressDesc[1]); // 城市
|
|
|
+ orderData.put("consignee", machineInfo.getUserMachineAddressName()); // 收货人
|
|
|
+ orderData.put("district_name", addressDesc[2]); // 区域
|
|
|
+ orderData.put("email", ""); // email
|
|
|
+ orderData.put("goods_amount", productColor.getColorDiscount() / 100); // 商品总价
|
|
|
+ orderData.put("goods_count", 1); // 产品数量
|
|
|
+ orderData.put("mobile", machineInfo.getUserMachineAddressTel()); // 手机号码
|
|
|
+ orderData.put("money_paid", productColor.getColorDiscount() / 100); // 已付款
|
|
|
+ orderData.put("oid", "DH00000000" + machineInfo.getUserMachineId()); // 订单号
|
|
|
+ orderData.put("order_amount", productColor.getColorDiscount() / 100); // 应付款,应付款金额要与已付款金额相同
|
|
|
+ /**
|
|
|
+ * 产品信息
|
|
|
+ */
|
|
|
+ List<Map<String, Object>> maps = new ArrayList<Map<String, Object>>();
|
|
|
+ Map<String, Object> orders1 = new HashMap<String, Object>();
|
|
|
+ orders1.put("goods_name", "【美国watero】净饮水一体机"); // 产品名称
|
|
|
+ orders1.put("goods_number", 1); // 产品数量
|
|
|
+ orders1.put("goods_price", productColor.getColorDiscount() / 100); // 产品原价
|
|
|
+ orders1.put("outer_sku", productColor.getColor69Code()); // 产品SKU
|
|
|
+ orders1.put("payment_ft", productColor.getColorDiscount() / 100); // 产品分摊价
|
|
|
+ maps.add(orders1);
|
|
|
+ orderData.put("orders", maps); // 订单产品
|
|
|
+ orderData.put("pay_name", "weixinpay"); // 支付方式
|
|
|
+ orderData.put("pay_time", DateTimeUtil.format(new Date()));// 支付时间
|
|
|
+ orderData.put("postscript",""); // 买家留言
|
|
|
+ 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", machineInfo.getUserMachineAddressTel()); // 我司电话
|
|
|
+ orderData.put("to_buyer", ""); // 商家备注
|
|
|
+ //orderData.put("total_amount", (order.getSalesAmount()/100.0)); // 订单总额
|
|
|
+ orderData.put("total_amount", (productColor.getColorDiscount() / 100)); // 订单总额
|
|
|
+ orderData.put("user_name", machineInfo.getUserMachineOpenId()); // 买家账户 百胜根据user_name来判断是否有重复,传openId是为了防止重复
|
|
|
+ orderData.put("zipcode", "000000"); // 邮编
|
|
|
+
|
|
|
+
|
|
|
+ com.fasterxml.jackson.databind.ObjectMapper mapper = new ObjectMapper();
|
|
|
+ String orderDataStr = null;
|
|
|
+ ;
|
|
|
+ try {
|
|
|
+ orderDataStr = mapper.writeValueAsString(orderData);
|
|
|
+ } catch (JsonProcessingException e2) {
|
|
|
+ e2.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ requestData.put("info", orderDataStr);
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ String result = HttpClient431Util.doPost(requestData, url);
|
|
|
+ result = StringEscapeUtils.unescapeJava(result); // unicode 编码
|
|
|
+ // parse JSON String to Object
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(result);
|
|
|
+ //JSONObject respData = JSONObject.fromObject(jsonObject.get("resp_data"));
|
|
|
+ String oderSn = jsonObject.getString("oder_sn");
|
|
|
+ if (oderSn != null) {
|
|
|
+ String msg = jsonObject.getString("msg");
|
|
|
+ if ("success".equals(msg)) {
|
|
|
+ throw new RuntimeException();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new Exception(jsonObject.getString("msg"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*// 推送百胜
|
|
|
try {
|
|
|
efastOrderService.giftCard(machineInfo.getUserMachineAddressInfo(), "DH00000000" + machineInfo.getUserMachineId(), machineInfo.getUserMachineColorId()
|
|
|
, machineInfo.getUserMachineAddressName(), machineInfo.getUserMachineAddressTel(), machineInfo.getUserMachineOpenId());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }
|
|
|
+ }*/
|
|
|
return presentMachineAndClearAgentCardNum(agentInfo);
|
|
|
}
|
|
|
|
|
@@ -164,8 +285,8 @@ public class GiftCardServiceImpl implements GiftCardService {
|
|
|
}
|
|
|
/**
|
|
|
* 批量添加礼品卡信息和赠送的机器物流信息
|
|
|
- * @param request
|
|
|
- * @param agentMachine
|
|
|
+ * @param
|
|
|
+ * @param
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|