|
|
@@ -16,6 +16,8 @@
|
|
|
*/
|
|
|
package org.springblade.salesPart.order.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -28,14 +30,18 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
|
|
+import okhttp3.*;
|
|
|
import org.springblade.client.entity.Message;
|
|
|
import org.springblade.client.feign.IMessageClient;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.jackson.JsonUtil;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.pay.tonglianPayment.entity.Parameters;
|
|
|
import org.springblade.pay.tonglianPayment.entity.WechatMark;
|
|
|
import org.springblade.pay.tonglianPayment.fegin.IPaymentClient;
|
|
|
+import org.springblade.pay.tonglianPayment.fegin.ITongLianPaymentClient;
|
|
|
import org.springblade.purchase.sales.entity.IntegralDetail;
|
|
|
import org.springblade.purchase.sales.feign.IIntegralDetailClient;
|
|
|
import org.springblade.salesPart.brand.service.IBrandFigureService;
|
|
|
@@ -95,6 +101,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.MathContext;
|
|
|
@@ -172,6 +179,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
|
|
|
private final IShipItemsRecordService shipItemsRecordService;
|
|
|
|
|
|
+ private final ITongLianPaymentClient parametersService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取销售订单详情
|
|
|
*
|
|
|
@@ -3985,7 +3994,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
} else {
|
|
|
pjShip.setStorageId(null);
|
|
|
}
|
|
|
-
|
|
|
+ pjShip.setGoodsNames(pjOrder.getGoodsNameJoin());
|
|
|
+ pjShip.setWhetherShippingNotice("1");
|
|
|
pjShip.setBusinesDate(new Date());
|
|
|
pjShip.setBillno(billNo);
|
|
|
pjShip.setOrdNo(pjOrder.getOrdNo());
|
|
|
@@ -4068,6 +4078,94 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, PjOrder> implemen
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ String stata = sysClient.getParamService("WeChat.shipping.notification");
|
|
|
+ if ("1".equals(stata)){
|
|
|
+ Parameters parameters = parametersService.getParametersOne();
|
|
|
+ if (ObjectUtils.isNull(parameters)) {
|
|
|
+ throw new SecurityException("未找到小程序信息");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(parameters.getAppSecret())) {
|
|
|
+ throw new SecurityException("未找到小程序秘钥");
|
|
|
+ }
|
|
|
+ String appIds = parameters.getSubAppid();
|
|
|
+ String appSecrets = parameters.getAppSecret();
|
|
|
+ OkHttpClient client = new OkHttpClient();
|
|
|
+ //获得token
|
|
|
+ Request request = new Request.Builder().url("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appIds + "&secret=" + appSecrets + "").build();
|
|
|
+ try {
|
|
|
+ Response responseToken = client.newCall(request).execute();
|
|
|
+ System.err.println("获取token返回报文:" + responseToken);
|
|
|
+ //如果请求成功,解析数据
|
|
|
+ if (responseToken.isSuccessful()) {
|
|
|
+ String body = responseToken.body().string();
|
|
|
+ System.err.println("获取token返回body:" + body);
|
|
|
+ //得到一个JSON对象
|
|
|
+ JSONObject object = JSON.parseObject(body);
|
|
|
+ String accessToken = object.getString("access_token");
|
|
|
+// String accessToken = "85_sLvonvR6FtYMS2mR_f2Qn16zwRk_wcDe2blEC4jRmzHyb2FDBHr9JciAp6DPL5Ww3lR-cPhki2mAiotGkzD0DwbTv2C7OgVUjFHrgivduLoKHdsu7Hi9mApW5O8ONGdADASRK";
|
|
|
+ System.err.println("获取token返回accessToken:" + accessToken);
|
|
|
+ if (ObjectUtils.isNotNull(accessToken)) {
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ Map<String, Object> mapOrder = new HashMap<>();
|
|
|
+ mapOrder.put("order_number_type", 2);
|
|
|
+ mapOrder.put("mchid", parameters.getMerchantId());
|
|
|
+ mapOrder.put("transaction_id", pjOrder.getChnltrxid());
|
|
|
+ map1.put("order_key", mapOrder);
|
|
|
+ map1.put("delivery_mode", "UNIFIED_DELIVERY");
|
|
|
+ map1.put("logistics_type", "4");
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ Map<String, Object> mapGoods = new HashMap<>();
|
|
|
+ mapGoods.put("item_desc", ObjectUtils.isNull(pjOrder.getGoodsNameJoin()) ? "" : pjOrder.getGoodsNameJoin());
|
|
|
+ mapList.add(mapGoods);
|
|
|
+ map1.put("shipping_list", mapList);
|
|
|
+ map1.put("upload_time", formatter.format(new Date()));
|
|
|
+ R<User> res = userClient.userInfoById(pjOrder.getCreateUser());
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ throw new RuntimeException("未找到客户联系人对应用户信息");
|
|
|
+ }
|
|
|
+ System.err.println("获取用户openId:" + res.getData().getOpenId());
|
|
|
+ Map<String, String> mapUser = new HashMap<>();
|
|
|
+ mapUser.put("openid", res.getData().getOpenId());
|
|
|
+ map1.put("payer", mapUser);
|
|
|
+
|
|
|
+ System.err.println("请求参数body:" + map1);
|
|
|
+ //发送发货通知
|
|
|
+ Request requestShip = new Request.Builder()
|
|
|
+ .url("https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" + accessToken)
|
|
|
+ .method("post", RequestBody.create(MediaType.parse("application/json; charset=utf-8"), JsonUtil.toJson(map1)))
|
|
|
+ .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), JsonUtil.toJson(map1)))
|
|
|
+ .build();
|
|
|
+ try {
|
|
|
+ Response responsePhone = client.newCall(requestShip).execute();
|
|
|
+ System.err.println("发送发货通知返回内容:" + responsePhone);
|
|
|
+ //如果请求成功,解析数据
|
|
|
+ if (responsePhone.isSuccessful()) {
|
|
|
+ String bodyShip = responsePhone.body().string();
|
|
|
+ //得到一个JSON对象
|
|
|
+ JSONObject objectShip = JSON.parseObject(bodyShip);
|
|
|
+ String status = objectShip.getString("errmsg");
|
|
|
+ if ("ok".equals(status)) {
|
|
|
+ return R.data("操作成功");
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("发送失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("发送失败");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("access_token获取失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("发送失败");
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
// 创建线程池
|
|
|
ExecutorService executor = Executors.newSingleThreadExecutor();
|
|
|
// 启动任务并提交给线程池
|