@ -1,11 +1,10 @@
package co.yixiang.modules.inform.service.impl ;
package co.yixiang.modules.inform ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.core.util.StrUtil ;
import cn.hutool.json.JSONUtil ;
import cn.hutool.json.JSONUtil ;
import cn.iocoder.yudao.framework.common.exception.YshopException ;
import cn.iocoder.yudao.framework.common.exception.YshopException ;
import co.yixiang.constant.SystemConfigConstants ;
import co.yixiang.constant.SystemConfigConstants ;
import co.yixiang.modules.inform.domin.* ;
import co.yixiang.modules.inform.domin.* ;
import co.yixiang.modules.inform.service.SendMsgService ;
import co.yixiang.modules.order.service.YxStoreOrderService ;
import co.yixiang.modules.order.service.YxStoreOrderService ;
import co.yixiang.modules.order.service.dto.YxStoreOrderDto ;
import co.yixiang.modules.order.service.dto.YxStoreOrderDto ;
import co.yixiang.modules.shop.service.YxSystemConfigService ;
import co.yixiang.modules.shop.service.YxSystemConfigService ;
@ -20,7 +19,8 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils ;
import org.apache.http.util.EntityUtils ;
import org.jsoup.nodes.Element ;
import org.jsoup.nodes.Element ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Component ;
import java.text.SimpleDateFormat ;
import java.text.SimpleDateFormat ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.HashMap ;
@ -28,21 +28,17 @@ import java.util.Map;
import org.jsoup.Jsoup ;
import org.jsoup.Jsoup ;
import org.jsoup.nodes.Document ;
import org.jsoup.nodes.Document ;
import org.jsoup.nodes.Node ;
import org.jsoup.nodes.TextNode ;
@Component
@Service
public class SendMsgService {
public class SendMsgServiceImpl implements SendMsgService {
@Autowired
@Autowired
private YxStoreOrderService yxStoreOrderService ;
private YxStoreOrderService yxStoreOrderService ;
@Autowired
private TemplateCard templateCard ;
@Autowired
@Autowired
private YxSystemConfigService systemConfigService ;
private YxSystemConfigService systemConfigService ;
@SneakyThrows
@SneakyThrows
@Override
public String inform ( long orderId , int type ) {
public String inform ( long orderId , int type ) {
CloseableHttpClient httpClient = HttpClients . createDefault ( ) ; //实例化对象
CloseableHttpClient httpClient = HttpClients . createDefault ( ) ; //实例化对象
// String webhook_url="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a2f0f8c9-e406-4f6b-86e4-d6ac9e4df88e";
// String webhook_url="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a2f0f8c9-e406-4f6b-86e4-d6ac9e4df88e";
@ -97,13 +93,16 @@ public class SendMsgServiceImpl implements SendMsgService {
arrayList . add ( new HorizontalContent ( ) . setKeyname ( "备注说明" ) . setValue ( list . get ( 1 ) . text ( ) . substring ( 5 ) . length ( ) = = 0 ? list . get ( 1 ) . text ( ) . substring ( 5 ) : "本次退款无备注" ) ) ;
arrayList . add ( new HorizontalContent ( ) . setKeyname ( "备注说明" ) . setValue ( list . get ( 1 ) . text ( ) . substring ( 5 ) . length ( ) = = 0 ? list . get ( 1 ) . text ( ) . substring ( 5 ) : "本次退款无备注" ) ) ;
arrayList . add ( new HorizontalContent ( ) . setKeyname ( "申请时间" ) . setValue ( list . get ( 2 ) . text ( ) . substring ( 5 ) ) ) ;
arrayList . add ( new HorizontalContent ( ) . setKeyname ( "申请时间" ) . setValue ( list . get ( 2 ) . text ( ) . substring ( 5 ) ) ) ;
}
}
templateCard . setHorizontal_content_list ( arrayList ) ;
templateCard . setCard_type ( "text_notice" ) ;
// templateCard.setHorizontal_content_list(arrayList);
templateCard . setSource ( new Souce ( ) . setDesc ( "眼界甄选" ) . setIcon_url ( "https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0" ) . setDesc_color ( 0 ) ) ;
// templateCard.setCard_type("text_notice");
templateCard . setMain_title ( new MainTitle ( ) . setTitle ( mainTitle ) . setDesc ( "订单号:" + orderId ) ) ;
// templateCard.setSource(new Souce().setDesc("眼界甄选").setIcon_url("https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0").setDesc_color(0));
templateCard . setEmphasis_content ( new EmphasisContent ( ) . setTitle ( yxStoreOrderDto . getPayPrice ( ) . toString ( ) ) . setDesc ( "订单总金额" ) ) ;
// templateCard.setMain_title(new MainTitle().setTitle(mainTitle).setDesc("订单号:"+orderId));
// templateCard.setQuote_area(new QuoteArea().setType(0).setUrl("").setAppid("APPID").setTitle("订单详情").setQuote_text("眼镜*1 0.01"));
// templateCard.setEmphasis_content(new EmphasisContent().setTitle(yxStoreOrderDto.getPayPrice().toString()).setDesc("订单总金额"));
templateCard . setSub_title_text ( "订单类型:" + yxStoreOrderDto . getPinkName ( ) ) ; //订单类型
//// templateCard.setQuote_area(new QuoteArea().setType(0).setUrl("").setAppid("APPID").setTitle("订单详情").setQuote_text("眼镜*1 0.01"));
// templateCard.setSub_title_text("订单类型:"+yxStoreOrderDto.getPinkName());//订单类型
// templateCard.setJump_list(arrayList1);
// templateCard.setCard_action(new CardAction().setType(1).setUrl(cardActionUrl));
ArrayList < Jump > arrayList1 = new ArrayList < > ( ) ;
ArrayList < Jump > arrayList1 = new ArrayList < > ( ) ;
//机器人消息跳转地址
//机器人消息跳转地址
String cardActionUrl = systemConfigService . getData ( SystemConfigConstants . CARD_ACTION_URL ) ;
String cardActionUrl = systemConfigService . getData ( SystemConfigConstants . CARD_ACTION_URL ) ;
@ -112,9 +111,20 @@ public class SendMsgServiceImpl implements SendMsgService {
cardActionUrl = "未配置跳转网址" ;
cardActionUrl = "未配置跳转网址" ;
}
}
arrayList1 . add ( new Jump ( ) . setType ( 1 ) . setUrl ( cardActionUrl ) . setTitle ( "前去处理订单" ) ) ;
arrayList1 . add ( new Jump ( ) . setType ( 1 ) . setUrl ( cardActionUrl ) . setTitle ( "前去处理订单" ) ) ;
templateCard . setJump_list ( arrayList1 ) ;
templateCard . setCard_action ( new CardAction ( ) . setType ( 1 ) . setUrl ( cardActionUrl ) ) ;
return TemplateCard . builder ( )
return templateCard ;
. horizontalContentList ( arrayList ) . card_type ( "text_notice" )
. source ( Souce . builder ( )
. desc ( "眼界甄选" )
. icon_url ( "https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0" )
. desc_color ( 0 )
. build ( ) )
. main_title ( MainTitle . builder ( ) . title ( mainTitle ) . desc ( "订单号:" + orderId ) . build ( ) )
. emphasis_content ( EmphasisContent . builder ( ) . title ( yxStoreOrderDto . getPayPrice ( ) . toString ( ) ) . desc ( "订单总金额" ) . build ( ) )
. sub_title_text ( "订单类型:" + yxStoreOrderDto . getPinkName ( ) )
. jump_list ( arrayList1 )
. card_action ( CardAction . builder ( ) . type ( 1 ) . url ( cardActionUrl ) . build ( ) )
. build ( ) ;
}
}
}
}