更新价格

dev
袁野 4 weeks ago
parent 745eb2e35b
commit a1f0999368
  1. 11
      bweb/pom.xml
  2. 55
      bweb/src/main/java/com/bweb/controller/TestController.java
  3. 31
      cweb/src/main/java/com/cweb/controller/goods/GoodsController.java
  4. 61
      cweb/src/main/java/com/cweb/controller/output/OutputController.java
  5. 14
      order/src/main/java/com/order/consumer/OrderCancelConsumer.java
  6. 11
      service/pom.xml
  7. 47
      service/src/main/java/com/hfkj/config/AliMessageConfig.java
  8. 100
      service/src/main/java/com/hfkj/config/PkgAnalyzeConfig.java
  9. 185
      service/src/main/java/com/hfkj/config/ShanGaoConfig.java
  10. 3
      service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java
  11. 32
      service/src/main/java/com/hfkj/model/OpenAccountRequestDto.java
  12. 6
      user/pom.xml
  13. 2
      user/src/main/java/com/user/controller/SmsController.java

@ -38,6 +38,17 @@
<version>2.0</version>
<systemPath>${basedir}/lib/open-api-sdk-2.0-jd.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.39.104.ALL</version>
</dependency>
</dependencies>
<build>

@ -1,17 +1,23 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.*;
import com.hfkj.config.AliMessageConfig;
import com.hfkj.config.CommonSysConst;
import com.hfkj.config.ShanGaoConfig;
import com.hfkj.entity.*;
import com.hfkj.haioil.HaiOilService;
import com.hfkj.jd.JdPostService;
import com.hfkj.jd.JdService;
import com.hfkj.mer.BsMerPayConfigService;
import com.hfkj.model.OpenAccountRequestDto;
import com.hfkj.model.ResponseData;
import com.hfkj.model.goods.JdGoodsModel;
@ -190,7 +196,20 @@ public class TestController {
}
}
@RequestMapping(value="/cancelOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "cancelOrder")
public ResponseData cancelOrder(@RequestParam(value = "thirdOrderNo", required = false) String thirdOrderNo,
@RequestParam(value = "childOrderNo", required = false) String childOrderNo) {
try {
JdPostService.cancelOrder(jdService.getToken(), Long.valueOf(thirdOrderNo), childOrderNo , "取消订单!");
return ResponseMsgUtil.success("取消");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/automaticData",method = RequestMethod.GET)
@ -294,10 +313,18 @@ public class TestController {
@RequestMapping(value="/aliMessage",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "阿里云短信推送")
public ResponseData aliMessage() {
try {
return ResponseMsgUtil.success(AliMessageConfig.sendSmsCode("18090580471" , "123654" , "SMS_480970320"));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getOrderCancelProcessDetail",method = RequestMethod.GET)
@ -314,6 +341,28 @@ public class TestController {
}
@RequestMapping(value="/shanGaoUrl",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "山高地址")
public ResponseData shanGaoUrl() {
try {
OpenAccountRequestDto openAccountRequestDto = new OpenAccountRequestDto();
openAccountRequestDto.setMethod("POST");
openAccountRequestDto.setMobile("18090580471");
openAccountRequestDto.setSource(ShanGaoConfig.sourceQwl);
String bizResponse = ShanGaoConfig.sendMessage("/product/common/inside/open_account",
JSON.toJSONString(openAccountRequestDto) , ShanGaoConfig.appidQwl , ShanGaoConfig.homeQwlPrivateKey , ShanGaoConfig.originQwlPublicKey);
JSONObject jsonObject = JSON.parseObject(bizResponse);
String url = "https://fin.etcsd.com/lionb/index.html?source=" + ShanGaoConfig.sourceQwl + "&marketcode=" + ShanGaoConfig.marketcodQwl + "&userId=" + jsonObject.getString("result");
return ResponseMsgUtil.success(url);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}

@ -9,9 +9,11 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.PageUtil;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.*;
import com.hfkj.jd.JdService;
import com.hfkj.model.CmsContentModel;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.goods.GoodsModel;
@ -27,6 +29,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -57,12 +60,18 @@ public class GoodsController {
@Resource
private GoodsVpdService goodsVpdService;
@Autowired
private RedisUtil redisUtil;
@Resource
private JdService jdService;
@Resource
private CouponDiscountService couponDiscountService;
// 缓存前缀KEY
public final static String CACHE_KEY = "GOODS_TYPE:";
// 订单缓存时间 24小时
public final static Integer CACHE_TIME = 60*60*24;
@RequestMapping(value="/getListGoodsType",method = RequestMethod.GET)
@ResponseBody
@ -117,6 +126,8 @@ public class GoodsController {
@RequestParam(value = "discountId", required = false) Integer discountId,
@RequestParam(value = "goodsBrand", required = false) Long goodsBrand,
@RequestParam(value = "price", required = false) Integer price,
@RequestParam(value = "cache", required = false) Integer cache,
@RequestParam(value = "rand", required = false) Integer rand,
@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "saleNum", required = false) Integer saleNum,
@RequestParam(value = "limit", required = false) Integer limit,
@ -160,12 +171,28 @@ public class GoodsController {
Map<String, Object> mapSpecs = new HashMap<>();
mapSpecs.put("discountId", discountId);
// 查询规格可用优惠券
List<CouponDiscountGoodsRel> couponDiscountGoodsRel = couponDiscountService.getListGoodsRel(mapSpecs);
List<Long> sp = couponDiscountGoodsRel.stream().map(CouponDiscountGoodsRel::getSpecsId).collect(Collectors.toList());
map.put("specsId", sp);
}
List<JdGoodsModel> list = goodsMsgService.getListCrest(map);
List<JdGoodsModel> list;
if (cache != null && cache == 1) {
Object cacheObj = redisUtil.get(CACHE_KEY+goodsTypeParent);
if (cacheObj != null) {
list = (List<JdGoodsModel>) cacheObj;
} else {
if (rand != null && rand == 1) {
map.put("rand", rand);
map.put("sort", null);
}
list = goodsMsgService.getListCrest(map);
redisUtil.set(CACHE_KEY + goodsTypeParent, list, CACHE_TIME);
}
} else {
list = goodsMsgService.getListCrest(map);
}
// return ResponseMsgUtil.success(list);

@ -1,5 +1,6 @@
package com.cweb.controller.output;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.api.ApiMerService;
import com.hfkj.common.exception.ErrorCode;
@ -8,7 +9,9 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.common.utils.SignatureUtil;
import com.hfkj.config.ShanGaoConfig;
import com.hfkj.entity.*;
import com.hfkj.model.OpenAccountRequestDto;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.SecDictionaryService;
@ -96,6 +99,64 @@ public class OutputController {
}
@RequestMapping(value = "/getShanGaoUrl", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取山高路径")
public ResponseData getShanGaoUrl(@RequestBody JSONObject body) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("type"))
|| StringUtils.isBlank(body.getString("phone"))
|| StringUtils.isBlank(body.getString("sign"))
|| StringUtils.isBlank(body.getString("appid"))
) {
log.error("LoginController --> phone() error!", "请求参数校验失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询api商户信息
ApiMer apiMer = apiMerService.queryDetail(body.getString("appid"));
Map<String , Object> map = new HashMap<>();
map.put("appid" , body.getString("appid"));
map.put("phone" , body.getString("phone"));
map.put("type" , body.getInteger("type"));
String sign = SignatureUtil.createSign(map , apiMer.getAppSecret());
if (!body.getString("sign").equals(sign)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "签名校验失败!");
}
OpenAccountRequestDto openAccountRequestDto = new OpenAccountRequestDto();
openAccountRequestDto.setMethod("POST");
openAccountRequestDto.setMobile(body.getString("phone"));
String url = "";
// 1:嗨森逛 2:黔物联
if (body.getInteger("type") == 1) {
openAccountRequestDto.setSource(ShanGaoConfig.sourceHsg);
String bizResponse = ShanGaoConfig.sendMessage("/product/common/inside/open_account",
JSON.toJSONString(openAccountRequestDto) , ShanGaoConfig.appidHsg , ShanGaoConfig.homeHsgPrivateKey , ShanGaoConfig.originHsgPublicKey);
JSONObject jsonObject = JSON.parseObject(bizResponse);
url = "https://fin.etcsd.com/lionb/index.html?source=" + ShanGaoConfig.sourceHsg + "&marketcode=" + ShanGaoConfig.marketcodHsg + "&userId=" + jsonObject.getString("result");
} else if (body.getInteger("type") == 2) {
openAccountRequestDto.setSource(ShanGaoConfig.sourceQwl);
String bizResponse = ShanGaoConfig.sendMessage("/product/common/inside/open_account",
JSON.toJSONString(openAccountRequestDto) , ShanGaoConfig.appidQwl , ShanGaoConfig.homeQwlPrivateKey , ShanGaoConfig.originQwlPublicKey);
JSONObject jsonObject = JSON.parseObject(bizResponse);
url = "https://fin.etcsd.com/lionb/index.html?source=" + ShanGaoConfig.sourceQwl + "&marketcode=" + ShanGaoConfig.marketcodQwl + "&userId=" + jsonObject.getString("result");
}
return ResponseMsgUtil.success(url);
} catch (Exception e) {
log.error("GoodsDetailController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,7 +1,11 @@
package com.order.consumer;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.model.order.OrderModel;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.sysenum.order.OrderStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
@ -19,7 +23,13 @@ public class OrderCancelConsumer implements RocketMQListener<OrderModel> {
@Override
public void onMessage(OrderModel order) {
// 取消订单
orderService.cancel(order.getOrderNo(),true);
// 查询订单
OrderModel data = orderService.getDetail(order.getOrderNo());
if (data != null && data.getOrderStatus().equals(OrderStatusEnum.status1.getCode())) {
// 取消订单
orderService.cancel(data.getOrderNo(),true);
}
}
}

@ -230,6 +230,12 @@
<artifactId>easyexcel</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<!-- 请将 'the-latest-version' 替换为最新版本号:https://mvnrepository.com/artifact/com.aliyun/dysmsapi20170525 -->
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
@ -255,6 +261,11 @@
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.39.104.ALL</version>
</dependency>
<dependency>
<groupId>meituan.skd</groupId>

@ -0,0 +1,47 @@
package com.hfkj.config;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.dysmsapi20170525.Client;
public class AliMessageConfig {
public static Client createClient() throws Exception {
Config config = new Config()
// 配置 AccessKey ID,请确保代码运行环境配置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId("LTAI5tP9XgTDu49zAAQLGAtJ")
// 配置 AccessKey Secret,请确保代码运行环境配置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret("bHESLcgX17KZ9amioQi7LNFDL51hoM");
// System.getenv()方法表示获取系统环境变量,不要直接在getenv()中填入AccessKey信息。
// 配置 Endpoint。中国站请使用dysmsapi.aliyuncs.com
config.endpoint = "dysmsapi.aliyuncs.com";
return new Client(config);
}
public static SendSmsResponse sendSmsCode(String phone, String code , String templateCode) throws Exception{
// 初始化请求客户端
Client client = AliMessageConfig.createClient();
JSONObject jsonObject = new JSONObject();
jsonObject.put("code",code);
jsonObject.put("number",phone);
// 构造API请求对象,请替换请求参数值
SendSmsRequest sendSmsRequest = new SendSmsRequest()
.setPhoneNumbers(phone)
.setSignName("重庆惠付科技有限公司")
.setTemplateCode(templateCode)
// TemplateParam为序列化后的JSON字符串。其中\"表示转义后的双引号。
.setTemplateParam(jsonObject.toJSONString());
// 获取响应对象
return client.sendSms(sendSmsRequest);
}
}

@ -0,0 +1,100 @@
package com.hfkj.config;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;
/**
*
* 解析内部http请求包 http1.0不使用URLENCODE编码格式默认UTF-8<br>
*
* @author yuhanyang
* @version [版本号, 2014年12月2日]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class PkgAnalyzeConfig
{
private static final Logger LOGGER = Logger.getLogger(PkgAnalyzeConfig.class.getName());
/**
* 从输入流中读出所有字节
*
* @param is 输入流
* @return 字节数组
* @throws Exception
*/
public static byte[] getBytesFromStream(InputStream is)
throws Exception
{
byte[] buffer = new byte[1024];
byte[] all = null;
int rlegth = 0;
while ((rlegth = is.read(buffer)) != -1)
{
if (all == null)
{
all = new byte[rlegth];
System.arraycopy(buffer, 0, all, 0, rlegth);
}
else
{
byte[] bftmp = new byte[all.length];
System.arraycopy(all, 0, bftmp, 0, all.length);
all = new byte[all.length + rlegth];
System.arraycopy(bftmp, 0, all, 0, bftmp.length);
System.arraycopy(buffer, 0, all, bftmp.length, rlegth);
}
}
return all;
}
/**
* 从输入流中读取字符串
*
* @param is 输入流
* @param charset 字符串编码格式
* @return 字符串
* @throws Exception
*/
public static String getStringFromStream(InputStream is, String charset)
throws Exception
{
byte all[] = getBytesFromStream(is);
return new String(all, charset);
}
// 从流中读取指定长度的字节
public static byte[] getFixedBytesFromStream(InputStream in, int length)
throws IOException
{
LOGGER.info("Begin Read of the InputStream...");
byte[] packBytes = new byte[length];
int readLen = in.read(packBytes, 0, length);
LOGGER.info("The [1] Read Length: " + readLen);
if (readLen < 0)
{
throw new IOException("The InputStream is Closed!");
}
int soReadLength = readLen;
int noReadLength = length - soReadLength;
int readTimes = 1;
while (noReadLength > 0)
{
readTimes++;
readLen = in.read(packBytes, soReadLength, noReadLength);
LOGGER.info("The [" + readTimes + "] Read Length: " + readLen);
if (readLen < 0)
{
break;
}
soReadLength = soReadLength + readLen;
noReadLength = length - soReadLength;
}
LOGGER.info("End Read of the InputStream...");
return packBytes;
}
}

@ -0,0 +1,185 @@
package com.hfkj.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alipay.api.internal.util.AlipaySignature;
import com.hfkj.common.pay.entity.AliPayReqInfo;
import com.hfkj.common.utils.HttpsUtils;
import io.netty.handler.codec.http.HttpUtil;
import javax.net.ssl.SSLSocketFactory;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.URL;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import java.util.logging.Logger;
public class ShanGaoConfig {
// FinanceGateway测试的调用地址 https://tsfin-fin-test.xlkeji.net/gateway/openapi/v2
// FinanceGateway生产的调用地址:https://fin.etcsd.com/gateway/openapi/v2
private static final String prodUrl = "https://fin.etcsd.com/gateway/openapi/v2";
// 第三方的私钥,生成地址:https://www.bejson.com/enc/rsa/,秘钥长度最好选择512bit
// 生成完成密钥对,提供公钥给山高信联,私钥填写homePrivateKey值,注意去掉回行符号
public static final String homeHsgPrivateKey = "MIIBVwIBADANBgkqhkiG9w0BAQEFAASCAUEwggE9AgEAAkEA31zt6gmGLlOwKX29yLrHPamNJq1KIkmHZOdKYMGmz1U1g3OAQU7Uttq8VH3nVC6ITQ5CrmNYb1VVfnCFBqfU5wIDAQABAkEA2dy3hkZh5X/lXKLz4P0lZySgs6/klkrnz+i1KGjaPnDIODHlRI2uFkYswhj29sJKL8mHHK1ARhy8YW7w3uOB2QIhAPpXX4leMAAFLR6WQ/RnIwks8V59aCtVG4E7XEfMjU8LAiEA5Glxf8QdhtYpOYqa+THRkjQ/CGj7q0G7v1sv0KxMqxUCIQD4Hj8fTE3wxzCX/0Ds7IgKIRQ9nbfwMtMm++mTdAaeTwIhAL653XBWjmE9CwdlWaqjkt+GiOu43g1OwjszJWYVuZ9RAiEAj1eh8EKwGSQlHP6gxz0FFGPoHApk+MKglhcXddOYVuQ=";
public static final String homeQwlPrivateKey = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAluzRK15LPIbOxsEr42Nzwk7YPgWfVOIg+QfLkouzD2bpUt9FZ3crSk8bUVGlAeAG0JteTGhwceHoEp0kF4UxywIDAQABAkB7NRbI3bBz1+Vj8fyfI+gzXuQ/NZ3N0NB0G/3/Q1ZJIkwzatq0yEmyq51jSr2MAe1wdDdPiKgYMZN0bo/Ss6LRAiEAxm8iOdS/8iu028wTIXf8wWfUTnPuRSpriL+lPsJWEPMCIQDCtWLlYZ4HLKKkAoOF85Ij2b4U544GDFEuOcGebFdRyQIhAKPt2YuHC49HtiDCZaeHlWI9oXGyakvvcGjHUf8X0rwrAiABFyDxpeVLpv1WK8luw5lq5/o/hbhu4jzGJH6oE3U9uQIhAKZFMiv9k/FBVtKMBWM+HWoheFIQB/J6UXg3qTvJCi4T";
// 山高信联提供的的公钥
public static final String originHsgPublicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJpcnJO7WXtriUcoogINLne6l3OsOS6lcmRHClbLguCjN6sCEVmslucSZXB+LimvJO3+efJu7WXg5obY1mKwexUCAwEAAQ==";
public static final String originQwlPublicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANHjdKupahgGKslSi0DvEKS+owL5LL6jOrFumW9eL/81ieeaEDXJOHa1XmPTJO6+zQjOvqS0FFtNAMBNvIg8kkMCAwEAAQ==";
// 请求响应参数编码
private static final String charset = "UTF-8";
// 由山高信联分配给第三方的appid
public static final String appidHsg = "XL_PARTNER_HAISENGUANG";
public static final String appidQwl = "XL_PARTNER_QWLJCJPZHPT";
public static final String marketcodHsg = "7711147302";
public static final String marketcodQwl = "7711147375";
public static final String sourceHsg = "319";
public static final String sourceQwl = "320";
private static final Logger log = Logger.getLogger("ShanGaoConfig");
public static String sendMessage(String uri, String bizContent , String appid , String homePrivateKey , String originPublicKey) throws Exception {
String url = prodUrl + uri;
Map<String, String> sortedParams = new TreeMap<>();
sortedParams.put("appid", appid);
sortedParams.put("nonce_str", UUID.randomUUID().toString().replace("-", ""));
sortedParams.put("sign_type", "RSA2");
sortedParams.put("timestamp", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
sortedParams.put("version", "1.0");
sortedParams.put("biz_content", bizContent);
String signContent = AlipaySignature.getSignContent(sortedParams);
log.info("Signature data " + signContent);
String signature = AlipaySignature.rsa256Sign(signContent, homePrivateKey, charset);
log.info("Signature result " + signature);
sortedParams.put("sign", signature);
Iterator<Map.Entry<String, String>> iterator = sortedParams.entrySet().iterator();
int i = 0;
StringBuffer buffer = new StringBuffer();
while(iterator.hasNext())
{
Map.Entry<String, String> next = iterator.next();
if(i==0){
i++;
}else{
buffer.append("&");
}
String param = next.getKey() + "=" + URLEncoder.encode(next.getValue(), charset);
buffer.append(param);
}
String requestBody = buffer.toString();
log.info("Request url " + url);
log.info("Request body " + requestBody);
String responseBody = post(url, requestBody);
JSONObject jsonObject = JSON.parseObject(responseBody, Feature.OrderedField);
String sign = jsonObject.getString("sign");
String bizResponse = jsonObject.getString("biz_response");
log.info("Sign str: "+ bizResponse);
boolean rsa256CheckContent = AlipaySignature.rsa256CheckContent(bizResponse, sign, originPublicKey, charset);
log.info("Check sign " + rsa256CheckContent);
return bizResponse;
}
private static String post(String strUrl, String strMsg) throws Exception
{
Socket s = null;
try
{
URL url = new URL(strUrl);
String uri = url.getFile();
String ip = url.getHost();
int port = url.getPort();
String protocol = url.getProtocol();
if (-1 == port)
{
if ("https".equals(protocol))
{
port = 443;
}
else
{
port = 80;
}
}
if ("https".equals(protocol)) {
s = SSLSocketFactory.getDefault().createSocket(ip, port);
}else {
s = new Socket(ip, port);
}
s.setSoTimeout(60000);
int len = strMsg.getBytes(charset).length;
String httpHead = "";
httpHead += "POST " + uri + " HTTP/1.0\r\n";
httpHead += "Host: " + ip + ":" + port + "\r\n";
httpHead += "Accept: text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8\r\n";
httpHead += "Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3\r\n";
httpHead += "Accept-Encoding: \r\n";
httpHead += "Content-Type: application/x-www-form-urlencoded;charset=" + charset + "\r\n";
httpHead += "Content-length: " + len + "\r\n";
httpHead += "\r\n";
String sendStr = httpHead + strMsg;
log.info("The HTTP Request : " + sendStr);
OutputStream os = s.getOutputStream();
os.write(sendStr.getBytes(charset));
os.flush();
InputStream is = s.getInputStream();
String strRet = PkgAnalyzeConfig.getStringFromStream(is, charset);
log.info("The HTTP Response : " + strRet);
int sie = strRet.indexOf("\r\n\r\n", 0) < 0 ? 0 : strRet.indexOf("\r\n\r\n", 0);
return strRet.substring(sie).trim();
}
finally
{
if (null != s && !s.isClosed())
{
s.close();
s = null;
}
}
}
}

@ -34,6 +34,7 @@ import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuPoolInfoResponse;
import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuStateListResponse;
import com.jd.open.api.sdk.response.vopxx.VopMessageQueryTransByVopNormalResponse;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -460,7 +461,7 @@ public class JdServiceImpl implements JdService {
public void cancelOrder(String childNo){
try {
BsOrderGoods orderGoods = bsOrderGoodsService.findGoodsOrderByChild(childNo);
if (orderGoods.getThirdOrderNo() != null) {
if (orderGoods != null && StringUtils.isNotBlank(orderGoods.getThirdOrderNo())) {
JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "取消订单!");
}
} catch (Exception e) {

@ -0,0 +1,32 @@
package com.hfkj.model;
public class OpenAccountRequestDto {
String method;
String mobile;
String source;
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
}

@ -32,6 +32,12 @@
<version>2.0</version>
<systemPath>${basedir}/lib/open-api-sdk-2.0-jd.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

@ -1 +1 @@
package com.user.controller; import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.MemberValidateUtil; import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.MessageConfig; import com.hfkj.model.ResponseData; import com.hfkj.service.user.BsUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.Random; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/sms") @Api(value = "短信服务") public class SmsController { private static Logger log = LoggerFactory.getLogger(SmsController.class); @Resource private RedisUtil redisUtil; @RequestMapping(value = "/sendLoginSMSCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取登录验证码") public ResponseData sendLoginSMSCode(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("phone"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 生成随机6位验证码 String smsCode = String.valueOf(new Random().nextInt(899999) + 100000); MessageConfig.req(phone,smsCode, MessageConfig.HWMSG_ID7); // 验证码缓存5分钟 redisUtil.set("SMS_CODE:"+phone, smsCode, 60*5); return ResponseMsgUtil.success("短信发送成功"); } catch (Exception e) { log.error("SMSController --> getLoginSMSCode() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendBindCardSMSCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取绑定卡片验证码") public ResponseData sendBindCardSMSCode(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("phone"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 生成随机6位验证码 String smsCode = String.valueOf(new Random().nextInt(899999) + 100000); MessageConfig.req(phone,smsCode, MessageConfig.HWMSG_ID7); // 验证码缓存5分钟 redisUtil.set("SMS_CODE:"+phone, smsCode, 60*5); return ResponseMsgUtil.success("短信发送成功"); } catch (Exception e) { log.error("SMSController --> getLoginSMSCode() error!", e); return ResponseMsgUtil.exception(e); } } }
package com.user.controller; import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.MemberValidateUtil; import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.AliMessageConfig; import com.hfkj.model.ResponseData; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.Random; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/sms") @Api(value = "短信服务") public class SmsController { private static Logger log = LoggerFactory.getLogger(SmsController.class); @Resource private RedisUtil redisUtil; @RequestMapping(value = "/sendLoginSMSCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取登录验证码") public ResponseData sendLoginSMSCode(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("phone"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 生成随机6位验证码 String smsCode = String.valueOf(new Random().nextInt(899999) + 100000); AliMessageConfig.sendSmsCode(phone, smsCode , "SMS_480970320"); // 验证码缓存5分钟 redisUtil.set("SMS_CODE:"+phone, smsCode, 60*5); return ResponseMsgUtil.success("短信发送成功"); } catch (Exception e) { log.error("SMSController --> getLoginSMSCode() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendBindCardSMSCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取绑定卡片验证码") public ResponseData sendBindCardSMSCode(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("phone"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 生成随机6位验证码 String smsCode = String.valueOf(new Random().nextInt(899999) + 100000); AliMessageConfig.sendSmsCode(phone, smsCode , "SMS_480970320"); // 验证码缓存5分钟 redisUtil.set("SMS_CODE:"+phone, smsCode, 60*5); return ResponseMsgUtil.success("短信发送成功"); } catch (Exception e) { log.error("SMSController --> getLoginSMSCode() error!", e); return ResponseMsgUtil.exception(e); } } }
Loading…
Cancel
Save