|
@@ -90,7 +90,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.net.URLDecoder;
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -342,8 +345,8 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
tbIndent.setShopId(order.getShopId());
|
|
tbIndent.setShopId(order.getShopId());
|
|
|
baseMapper.insert(tbIndent);
|
|
baseMapper.insert(tbIndent);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- if (!tbIndent.getIndentState().equals("11")) {
|
|
|
|
|
|
|
+ log.info("订单类型:"+order.getOrderType()+",跑腿订单状态:"+tbIndent.getIndentState());
|
|
|
|
|
+ if (order.getOrderType() == 2 && !"11".equals(tbIndent.getIndentState())) {
|
|
|
// 创建快跑者订单
|
|
// 创建快跑者订单
|
|
|
log.info("第一次创建快跑者订单");
|
|
log.info("第一次创建快跑者订单");
|
|
|
String responseBody = creatSpeedRunnerOrder(order);
|
|
String responseBody = creatSpeedRunnerOrder(order);
|
|
@@ -382,6 +385,14 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
return Result.success();
|
|
return Result.success();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String shopId = URLEncoder.encode("火腿炒鸡蛋: null,福袋 /&脆皮烤鸭\uD83E\uDD86(双拼):null,++++++", "GBK");
|
|
|
|
|
+ System.out.println("shopId = " + shopId);
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
public String creatSpeedRunnerOrder(TbOrder tbOrder){
|
|
public String creatSpeedRunnerOrder(TbOrder tbOrder){
|
|
|
// 获取店铺信息
|
|
// 获取店铺信息
|
|
|
GoodsShop goodsShop = goodsShopService.getById(tbOrder.getShopId());
|
|
GoodsShop goodsShop = goodsShopService.getById(tbOrder.getShopId());
|
|
@@ -403,22 +414,175 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
Address address = addressService.getById(tbOrder.getAddressId());
|
|
Address address = addressService.getById(tbOrder.getAddressId());
|
|
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject body = new com.alibaba.fastjson.JSONObject();
|
|
com.alibaba.fastjson.JSONObject body = new com.alibaba.fastjson.JSONObject();
|
|
|
- body.put("shop_id", tbOrder.getShopId());
|
|
|
|
|
- body.put("shop_name", goodsShop.getShopName());
|
|
|
|
|
- body.put("shop_tel", goodsShop.getPhone());
|
|
|
|
|
- body.put("shop_address", goodsShop.getDetailedAddress());
|
|
|
|
|
- body.put("shop_tag", goodsShop.getShopLng() + "," + goodsShop.getShopLat());
|
|
|
|
|
- body.put("order_content", stringBuilder.toString());
|
|
|
|
|
- body.put("order_note", tbOrder.getRemark());
|
|
|
|
|
- body.put("order_mark", tbOrder.getOrderSequence());
|
|
|
|
|
- body.put("order_from", goodsShop.getShopName() + "#" + tbOrder.getOrderSequence());
|
|
|
|
|
- body.put("order_time", tbOrder.getPayTime());
|
|
|
|
|
- body.put("customer_name", address.getUserName());
|
|
|
|
|
- body.put("customer_tel", address.getUserPhone());
|
|
|
|
|
- body.put("customer_address", address.getAddressDetail());
|
|
|
|
|
- body.put("customer_tag", address.getLng() + "," + address.getLat());
|
|
|
|
|
- body.put("order_no", tbOrder.getOrderNumber());
|
|
|
|
|
- body.put("order_price", tbOrder.getPayMoney());
|
|
|
|
|
|
|
+ String shopId = tbOrder.getShopId()+"";
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(shopId)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ shopId = URLDecoder.decode(shopId, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("shop_id", shopId);
|
|
|
|
|
+
|
|
|
|
|
+ String shopName = goodsShop.getShopName();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(shopName)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ shopName = URLDecoder.decode(shopName, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+// shopName=shopName.replaceAll("\\+","-");
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("shop_name", shopName);
|
|
|
|
|
+
|
|
|
|
|
+ String phone = goodsShop.getPhone();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(phone)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ phone = URLDecoder.decode(phone, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("shop_tel", phone);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String detailedAddress = goodsShop.getDetailedAddress();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(detailedAddress)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ detailedAddress = URLDecoder.decode(detailedAddress, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+// detailedAddress=detailedAddress.replaceAll("\\+","-");
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("shop_address", detailedAddress);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String shopTag =goodsShop.getShopLng() + "," + goodsShop.getShopLat();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(detailedAddress)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ shopTag = URLDecoder.decode(shopTag, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("shop_tag", shopTag);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// 将+变成-
|
|
|
|
|
+ String orderContent = stringBuilder.toString();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(orderContent)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ orderContent = URLDecoder.decode(orderContent, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+// orderContent=orderContent.replaceAll("\\+","-");
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("order_content", orderContent);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String remark = tbOrder.getRemark();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(remark)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ remark = URLDecoder.decode(remark, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+// remark=remark.replaceAll("\\+","-");
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("order_note", remark);
|
|
|
|
|
+
|
|
|
|
|
+ String orderSequence = tbOrder.getOrderSequence();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(orderSequence)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ orderSequence =URLDecoder.decode(orderSequence, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("order_mark", orderSequence);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ body.put("order_from", shopName+ "#" + orderSequence);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String payTime = tbOrder.getPayTime();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(payTime)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ payTime = URLDecoder.decode(payTime, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("order_time", payTime);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String userName = address.getUserName();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(userName)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ userName = URLDecoder.decode(userName, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+// userName=userName.replaceAll("\\+","-");
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("customer_name", userName);
|
|
|
|
|
+
|
|
|
|
|
+ String userPhone = address.getUserPhone();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(userPhone)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ userPhone = URLDecoder.decode(userPhone, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("customer_tel", userPhone);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String addressDetail = address.getAddressDetail();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(addressDetail)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ addressDetail = URLDecoder.decode(addressDetail, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// addressDetail=addressDetail.replaceAll("\\+","-");
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("customer_address", addressDetail);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String customerTag=address.getLng() + "," + address.getLat();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(customerTag)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ customerTag = URLDecoder.decode(customerTag, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("customer_tag", customerTag);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String orderNumber = tbOrder.getOrderNumber();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(orderNumber)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ orderNumber = URLDecoder.decode(orderNumber, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("order_no", orderNumber);
|
|
|
|
|
+
|
|
|
|
|
+ String payMoney = tbOrder.getPayMoney().toPlainString();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(payMoney)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ payMoney = URLDecoder.decode(payMoney, "GBK");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ body.put("order_price",payMoney);
|
|
|
body.put("pay_status", 0);
|
|
body.put("pay_status", 0);
|
|
|
|
|
|
|
|
log.info("body信息:" + body);
|
|
log.info("body信息:" + body);
|
|
@@ -452,6 +616,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
log.info("创建结果:"+responseBody);
|
|
log.info("创建结果:"+responseBody);
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
|
+// throw new RuntimeException("responseBody");
|
|
|
}
|
|
}
|
|
|
return responseBody;
|
|
return responseBody;
|
|
|
}
|
|
}
|
|
@@ -1436,7 +1601,27 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
|
|
|
|
|
// 判断是否为当前骑手订单
|
|
// 判断是否为当前骑手订单
|
|
|
if (!Objects.equals(indentOrder.getRiderUserId(), userId)) {
|
|
if (!Objects.equals(indentOrder.getRiderUserId(), userId)) {
|
|
|
- throw new SqxException("不能完成非本人订单!");
|
|
|
|
|
|
|
+// 不为本人则需要调用转单接口
|
|
|
|
|
+ log.info("不为接单本人,需转单");
|
|
|
|
|
+ log.info("当前骑手id:"+indentOrder.getRiderUserId()+",需要更换的骑手id:"+userId);
|
|
|
|
|
+ UserEntity userEntity = userService.getById(userId);
|
|
|
|
|
+ indentOrder.setRiderUserId(userEntity.getUserId());
|
|
|
|
|
+ indentOrder.setIsRider(1);
|
|
|
|
|
+ updateById(indentOrder);
|
|
|
|
|
+ log.info("测试是否进入转单3");
|
|
|
|
|
+ String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
|
|
|
|
+ TransferRecordEntity tr = new TransferRecordEntity();
|
|
|
|
|
+ tr.setUserId(userEntity.getUserId());
|
|
|
|
|
+ tr.setUserName(userEntity.getUserName());
|
|
|
|
|
+ tr.setUserPhone(userEntity.getPhone());
|
|
|
|
|
+ tr.setOrderId(indentOrder.getOrderId());
|
|
|
|
|
+ tr.setReceveTime(format);
|
|
|
|
|
+ tr.setStationName(userEntity.getStationName());
|
|
|
|
|
+ tr.setDeleteFlag(0);
|
|
|
|
|
+ log.info("测试是否进入转单4,tr:"+ new Gson().toJson(tr));
|
|
|
|
|
+ int insertCount = transferRecordDao.insert(tr);
|
|
|
|
|
+ log.info("测试是否进入转单5,insertCount:"+insertCount);
|
|
|
|
|
+// throw new SqxException("不能完成非本人订单!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
RLock lock = redissonClient.getLock(String.format(RedisKey.UPDATE_INDENT_LOCK, indentOrder.getIndentNumber()));
|
|
RLock lock = redissonClient.getLock(String.format(RedisKey.UPDATE_INDENT_LOCK, indentOrder.getIndentNumber()));
|