Commit 7ab82873 authored by Quxl's avatar Quxl

x

parent f756b39e
package com.egolm.shop.api.service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page;
public interface OrderService {
public String orderCheck(Map<String,Object> params);
public String submit(JSONObject submitObj);
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page);
public String queryOrderDetailList(String salesOrderId);
public String getOrderDetail(String salesOrderId);
public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime);
public String getSubOrderDetail(String subOrderID);
public void cancelOrder(String sSalesOrderID);
public String submitByGroup(String orgNo, String shopNo, String prompPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public void confirmReceipt(String custNo, String subOrderID);
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID);
}
package com.egolm.shop.api.service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page;
public interface OrderService {
public String orderCheck(Map<String,Object> params);
public String submit(JSONObject submitObj);
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page);
public String queryOrderDetailList(String salesOrderId);
public String getOrderDetail(String salesOrderId);
public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime);
public String getSubOrderDetail(String subOrderID);
public void cancelOrder(String sSalesOrderID);
public String submitByGroup(String orgNo, String shopNo, String prompPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo);
public void confirmReceipt(String custNo, String subOrderID);
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID);
}
package com.egolm.shop.api.service.impl;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.QiyeWxService;
import com.egolm.shop.common.utils.HttpUtil;
import com.egolm.shop.common.utils.HttpUtil.HttpReqObject;
import com.egolm.shop.common.utils.HttpUtil.HttpRespObject;
import com.egolm.shop.common.utils.HttpUtil.JsonReqObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion;
@Service
public class QiyeWxServiceImpl implements QiyeWxService {
@Value("${qiyewx.corpid}")
private String corpid;
@Value("${qiyewx.corpsecret}")
private String corpsecret;
@Value("${qiyewx.baseUrl}")
private String baseUrl;
@Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid;
@Autowired
private RedisTemplate<String, String> redis;
@Override
public String getTokenString() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
Long systemTime = System.currentTimeMillis();
String tokenObjectString = redis.opsForValue().get(redisCacheKey);
if(StringUtil.isNotBlank(tokenObjectString)) {
JSONObject tokenObject = JSON.parseObject(tokenObjectString);
Integer errcode = tokenObject.getInteger("errcode");
if(errcode == 0) {
Long expires_in = tokenObject.getLong("expires_in");
String loadTimeString = tokenObject.getString("loadTime");
if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) {
Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss");
Long expireTime = loadTime.getTime() + (expires_in*1000L);
if((expireTime - DevTime) > systemTime) {
String access_token = tokenObject.getString("access_token");
if(StringUtil.isNotBlank(access_token)) {
return access_token;
}
}
}
}
}
String requestUrl = baseUrl + MessageFormat.format(UrlGetToken, corpid, corpsecret);
HttpRespObject resp = HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).get(new HttpReqObject(requestUrl, null, null));
if(resp.getHttpCode() == 200) {
String text = resp.getResponseBody();
JSONObject tokenObject = JSON.parseObject(text);
Integer code = tokenObject.getInteger("errcode");
if(code == 0) {
tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString());
return tokenObject.getString("access_token");
}
}
return null;
}
@Override
public void refreshToken() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
redis.delete(redisCacheKey);
}
@Override
public void sendMessage(WxMessage wxMessage) {
String tokenString = this.getTokenString();
String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString);
Map<String, String> headers = new HashMap<String, String>();
headers.put("content-type", "application/x-www-form-urlencoded");
wxMessage.getMiniprogram_notice().setAppid(redirectAppid);
HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).postJson(new JsonReqObject(requestUrl, wxMessage, headers));
}
}
package com.egolm.shop.api.service.impl;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.QiyeWxService;
import com.egolm.shop.api.service.QiyeWxService.WxMessage;
import com.egolm.shop.common.utils.HttpUtil;
import com.egolm.shop.common.utils.HttpUtil.HttpReqObject;
import com.egolm.shop.common.utils.HttpUtil.HttpRespObject;
import com.egolm.shop.common.utils.HttpUtil.JsonReqObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion;
@Service
public class QiyeWxServiceImpl implements QiyeWxService {
@Value("${qiyewx.corpid}")
private String corpid;
@Value("${qiyewx.corpsecret}")
private String corpsecret;
@Value("${qiyewx.baseUrl}")
private String baseUrl;
@Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid;
@Autowired
private RedisTemplate<String, String> redis;
@Override
public String getTokenString() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
Long systemTime = System.currentTimeMillis();
String tokenObjectString = redis.opsForValue().get(redisCacheKey);
if(StringUtil.isNotBlank(tokenObjectString)) {
JSONObject tokenObject = JSON.parseObject(tokenObjectString);
Integer errcode = tokenObject.getInteger("errcode");
if(errcode == 0) {
Long expires_in = tokenObject.getLong("expires_in");
String loadTimeString = tokenObject.getString("loadTime");
if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) {
Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss");
Long expireTime = loadTime.getTime() + (expires_in*1000L);
if((expireTime - DevTime) > systemTime) {
String access_token = tokenObject.getString("access_token");
if(StringUtil.isNotBlank(access_token)) {
return access_token;
}
}
}
}
}
String requestUrl = baseUrl + MessageFormat.format(UrlGetToken, corpid, corpsecret);
HttpRespObject resp = HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).get(new HttpReqObject(requestUrl, null, null));
if(resp.getHttpCode() == 200) {
String text = resp.getResponseBody();
JSONObject tokenObject = JSON.parseObject(text);
Integer code = tokenObject.getInteger("errcode");
if(code == 0) {
tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString());
return tokenObject.getString("access_token");
}
}
return null;
}
@Override
public void refreshToken() {
String redisCacheKey = PrefixRedisTokenKey + corpid;
redis.delete(redisCacheKey);
}
@Override
public void sendMessage(WxMessage wxMessage) {
String tokenString = this.getTokenString();
String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString);
Map<String, String> headers = new HashMap<String, String>();
headers.put("content-type", "application/x-www-form-urlencoded");
wxMessage.getMiniprogram_notice().setAppid(redirectAppid);
HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).postJson(new JsonReqObject(requestUrl, wxMessage, headers));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment