|
@@ -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();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ 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", "");
|
|
|
+ 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());
|
|
|
+ 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);
|
|
|
+ orderData.put("shipping_fee", 0);
|
|
|
+ orderData.put("shipping_name", "yto");
|
|
|
+ orderData.put("tel", machineInfo.getUserMachineAddressTel());
|
|
|
+ orderData.put("to_buyer", "");
|
|
|
+
|
|
|
+ orderData.put("total_amount", (productColor.getColorDiscount() / 100));
|
|
|
+ orderData.put("user_name", machineInfo.getUserMachineOpenId());
|
|
|
+ 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);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(result);
|
|
|
+
|
|
|
+ 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
|
|
|
*/
|