|
@@ -24,16 +24,12 @@ import com.github.wxpay.sdk.WXPay;
|
|
|
import com.sqx.common.constant.RedisKey;
|
|
import com.sqx.common.constant.RedisKey;
|
|
|
import com.sqx.common.exception.SqxException;
|
|
import com.sqx.common.exception.SqxException;
|
|
|
import com.sqx.common.sms.SmsSendResult;
|
|
import com.sqx.common.sms.SmsSendResult;
|
|
|
-import com.sqx.common.utils.Constant;
|
|
|
|
|
-import com.sqx.common.utils.DateUtils;
|
|
|
|
|
-import com.sqx.common.utils.DistanceUtil;
|
|
|
|
|
-import com.sqx.common.utils.MyGlobalThreadPool;
|
|
|
|
|
-import com.sqx.common.utils.PageUtils;
|
|
|
|
|
-import com.sqx.common.utils.Result;
|
|
|
|
|
|
|
+import com.sqx.common.utils.*;
|
|
|
import com.sqx.modules.activity.entity.ActivityPartRecord;
|
|
import com.sqx.modules.activity.entity.ActivityPartRecord;
|
|
|
import com.sqx.modules.activity.service.ActivityPartRecordService;
|
|
import com.sqx.modules.activity.service.ActivityPartRecordService;
|
|
|
import com.sqx.modules.activity.service.ActivityService;
|
|
import com.sqx.modules.activity.service.ActivityService;
|
|
|
import com.sqx.modules.activity.vo.OrderSuitActivityVO;
|
|
import com.sqx.modules.activity.vo.OrderSuitActivityVO;
|
|
|
|
|
+import com.sqx.modules.address.dao.AddressDao;
|
|
|
import com.sqx.modules.address.entity.Address;
|
|
import com.sqx.modules.address.entity.Address;
|
|
|
import com.sqx.modules.address.service.AddressService;
|
|
import com.sqx.modules.address.service.AddressService;
|
|
|
import com.sqx.modules.app.dao.UserBrowseDao;
|
|
import com.sqx.modules.app.dao.UserBrowseDao;
|
|
@@ -109,6 +105,11 @@ import com.sqx.modules.utils.excel.ExcelData;
|
|
|
import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
|
import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.redisson.api.RLock;
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
@@ -129,6 +130,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
@@ -1828,6 +1830,23 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
// 生成跑腿订单
|
|
// 生成跑腿订单
|
|
|
tbIndentService.insertIndent(tbOrder);
|
|
tbIndentService.insertIndent(tbOrder);
|
|
|
|
|
|
|
|
|
|
+ // 创建快跑者订单
|
|
|
|
|
+ String responseBody = creatSpeedRunnerOrder(tbOrder);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(responseBody)) {
|
|
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(responseBody);
|
|
|
|
|
+ log.info("jsonObject = " + jsonObject);
|
|
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
|
|
+ if (code!=200) {
|
|
|
|
|
+ String message = jsonObject.getString("message");
|
|
|
|
|
+ if (!"该订单已存在,请勿重复提交".equals(message)) {
|
|
|
|
|
+ creatSpeedRunnerOrder(tbOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ creatSpeedRunnerOrder(tbOrder);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//设置小程序消息推送
|
|
//设置小程序消息推送
|
|
|
CommonInfo one = commonInfoService.findOne(269);
|
|
CommonInfo one = commonInfoService.findOne(269);
|
|
|
List<String> msgList = new ArrayList<>();
|
|
List<String> msgList = new ArrayList<>();
|
|
@@ -3002,4 +3021,79 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
lock.unlock();
|
|
lock.unlock();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public String creatSpeedRunnerOrder(TbOrder tbOrder){
|
|
|
|
|
+// 获取店铺信息
|
|
|
|
|
+ GoodsShop goodsShop = goodsShopService.getById(tbOrder.getShopId());
|
|
|
|
|
+// 获取餐品信息
|
|
|
|
|
+ List<OrderGoods> orderGoodsList = orderGoodsDao.selectList(new QueryWrapper<OrderGoods>()
|
|
|
|
|
+ .eq("order_id", tbOrder.getOrderId()));
|
|
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
|
+ for (int i = 0; i < orderGoodsList.size(); i++) {
|
|
|
|
|
+ OrderGoods orderGoods = orderGoodsList.get(i);
|
|
|
|
|
+ String skuMessage = orderGoods.getSkuMessage();
|
|
|
|
|
+ String goodsName = orderGoods.getGoodsName();
|
|
|
|
|
+ if (i == 0) {
|
|
|
|
|
+ stringBuilder.append(goodsName).append(": ").append(skuMessage);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ stringBuilder.append(",").append(goodsName).append(":").append(skuMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// 获取用户收货地址
|
|
|
|
|
+ Address address = addressService.getById(tbOrder.getAddressId());
|
|
|
|
|
+
|
|
|
|
|
+ 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", tbOrder.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());
|
|
|
|
|
+ body.put("pay_status", 0);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("body信息:" + body);
|
|
|
|
|
+
|
|
|
|
|
+// 版本
|
|
|
|
|
+ String version = "1";
|
|
|
|
|
+// 时间戳
|
|
|
|
|
+ long currentTimeMillis = System.currentTimeMillis();
|
|
|
|
|
+ long currentTimeSeconds = currentTimeMillis / 1000;
|
|
|
|
|
+ String timestamp = String.valueOf(currentTimeSeconds);
|
|
|
|
|
+// 唯一标识符
|
|
|
|
|
+ String ticket = "83f0ff99-7c8e-47e8-8802-bd3754414a52";
|
|
|
|
|
+// 团队token
|
|
|
|
|
+ String teamToken = "Q444DMV4LT8WSGRW";
|
|
|
|
|
+// 开发者中心的开发密钥
|
|
|
|
|
+ String devKey = "31RRHA4O165VFN9W2DAPDYDH8N83BT12";
|
|
|
|
|
+
|
|
|
|
|
+// 获取签名
|
|
|
|
|
+ String sign = com.sqx.common.utils.SignUtil.getSign(body.toString(), devKey, teamToken, ticket, currentTimeSeconds, 1);
|
|
|
|
|
+ String responseBody="";
|
|
|
|
|
+ try {
|
|
|
|
|
+ log.info("创建快跑者订单");
|
|
|
|
|
+ CloseableHttpClient client = HttpClients.createDefault();
|
|
|
|
|
+ // 创建httppost
|
|
|
|
|
+ HttpPost httpPost = new HttpPost("https://open.keloop.cn/open/order/createOrder");
|
|
|
|
|
+ String params = "version=" + version + "×tamp=" + timestamp + "&ticket=" + ticket + "&team_token=" + teamToken + "&dev_key=" + devKey + "&sign=" + sign + "&body=" + body.toString(); // 注意:这里不需要手动编码,HttpClient会处理它。
|
|
|
|
|
+ StringEntity entity = new StringEntity(params, StandardCharsets.UTF_8);
|
|
|
|
|
+ entity.setContentType("application/x-www-form-urlencoded"); // 设置Content-Type为application/x-www-form-urlencoded,但不是必须的,HttpClient会自动设置。
|
|
|
|
|
+ httpPost.setEntity(entity);
|
|
|
|
|
+ responseBody = EntityUtils.toString(client.execute(httpPost).getEntity());
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return responseBody;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|