Commit 7ab82873 authored by Quxl's avatar Quxl

x

parent f756b39e
package com.egolm.shop.api.service; package com.egolm.shop.api.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.jdbc.Page; import com.egolm.common.jdbc.Page;
public interface OrderService { public interface OrderService {
public String orderCheck(Map<String,Object> params); public String orderCheck(Map<String,Object> params);
public String submit(JSONObject submitObj); public String submit(JSONObject submitObj);
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page); public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page);
public String queryOrderDetailList(String salesOrderId); public String queryOrderDetailList(String salesOrderId);
public String getOrderDetail(String salesOrderId); public String getOrderDetail(String salesOrderId);
public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime); public void paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime);
public String getSubOrderDetail(String subOrderID); public String getSubOrderDetail(String subOrderID);
public void cancelOrder(String sSalesOrderID); 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 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 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 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 void confirmReceipt(String custNo, String subOrderID);
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID); public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID);
} }
package com.egolm.shop.api.service.impl; package com.egolm.shop.api.service.impl;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil; import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil; import com.egolm.common.StringUtil;
import com.egolm.shop.api.service.QiyeWxService; import com.egolm.shop.api.service.QiyeWxService;
import com.egolm.shop.common.utils.HttpUtil; import com.egolm.shop.api.service.QiyeWxService.WxMessage;
import com.egolm.shop.common.utils.HttpUtil.HttpReqObject; import com.egolm.shop.common.utils.HttpUtil;
import com.egolm.shop.common.utils.HttpUtil.HttpRespObject; import com.egolm.shop.common.utils.HttpUtil.HttpReqObject;
import com.egolm.shop.common.utils.HttpUtil.JsonReqObject; import com.egolm.shop.common.utils.HttpUtil.HttpRespObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion; import com.egolm.shop.common.utils.HttpUtil.JsonReqObject;
import com.egolm.shop.common.utils.HttpUtil.SSLVersion;
@Service
public class QiyeWxServiceImpl implements QiyeWxService { @Service
public class QiyeWxServiceImpl implements QiyeWxService {
@Value("${qiyewx.corpid}")
private String corpid; @Value("${qiyewx.corpid}")
private String corpid;
@Value("${qiyewx.corpsecret}")
private String corpsecret; @Value("${qiyewx.corpsecret}")
private String corpsecret;
@Value("${qiyewx.baseUrl}")
private String baseUrl; @Value("${qiyewx.baseUrl}")
private String baseUrl;
@Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid; @Value("${qiyewx.msg.redirect.appid}")
private String redirectAppid;
@Autowired
private RedisTemplate<String, String> redis; @Autowired
private RedisTemplate<String, String> redis;
@Override
public String getTokenString() { @Override
String redisCacheKey = PrefixRedisTokenKey + corpid; public String getTokenString() {
Long systemTime = System.currentTimeMillis(); String redisCacheKey = PrefixRedisTokenKey + corpid;
String tokenObjectString = redis.opsForValue().get(redisCacheKey); Long systemTime = System.currentTimeMillis();
if(StringUtil.isNotBlank(tokenObjectString)) { String tokenObjectString = redis.opsForValue().get(redisCacheKey);
JSONObject tokenObject = JSON.parseObject(tokenObjectString); if(StringUtil.isNotBlank(tokenObjectString)) {
Integer errcode = tokenObject.getInteger("errcode"); JSONObject tokenObject = JSON.parseObject(tokenObjectString);
if(errcode == 0) { Integer errcode = tokenObject.getInteger("errcode");
Long expires_in = tokenObject.getLong("expires_in"); if(errcode == 0) {
String loadTimeString = tokenObject.getString("loadTime"); Long expires_in = tokenObject.getLong("expires_in");
if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) { String loadTimeString = tokenObject.getString("loadTime");
Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss"); if(expires_in != null && StringUtil.isNotBlank(loadTimeString)) {
Long expireTime = loadTime.getTime() + (expires_in*1000L); Date loadTime = DateUtil.parse(loadTimeString, "yyyy-MM-dd HH:mm:ss");
if((expireTime - DevTime) > systemTime) { Long expireTime = loadTime.getTime() + (expires_in*1000L);
String access_token = tokenObject.getString("access_token"); if((expireTime - DevTime) > systemTime) {
if(StringUtil.isNotBlank(access_token)) { String access_token = tokenObject.getString("access_token");
return 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)); String requestUrl = baseUrl + MessageFormat.format(UrlGetToken, corpid, corpsecret);
if(resp.getHttpCode() == 200) { HttpRespObject resp = HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).get(new HttpReqObject(requestUrl, null, null));
String text = resp.getResponseBody(); if(resp.getHttpCode() == 200) {
JSONObject tokenObject = JSON.parseObject(text); String text = resp.getResponseBody();
Integer code = tokenObject.getInteger("errcode"); JSONObject tokenObject = JSON.parseObject(text);
if(code == 0) { Integer code = tokenObject.getInteger("errcode");
tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); if(code == 0) {
redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString()); tokenObject.put("loadTime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
return tokenObject.getString("access_token"); redis.opsForValue().set(redisCacheKey, tokenObject.toJSONString());
} return tokenObject.getString("access_token");
} }
return null; }
} return null;
}
@Override
public void refreshToken() { @Override
String redisCacheKey = PrefixRedisTokenKey + corpid; public void refreshToken() {
redis.delete(redisCacheKey); String redisCacheKey = PrefixRedisTokenKey + corpid;
} redis.delete(redisCacheKey);
}
@Override
public void sendMessage(WxMessage wxMessage) { @Override
String tokenString = this.getTokenString(); public void sendMessage(WxMessage wxMessage) {
String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString); String tokenString = this.getTokenString();
Map<String, String> headers = new HashMap<String, String>(); String requestUrl = baseUrl + MessageFormat.format(UrlSendMsg, tokenString);
headers.put("content-type", "application/x-www-form-urlencoded"); Map<String, String> headers = new HashMap<String, String>();
wxMessage.getMiniprogram_notice().setAppid(redirectAppid); headers.put("content-type", "application/x-www-form-urlencoded");
HttpUtil.newInstance().setSSLVersion(SSLVersion.SSLv3).postJson(new JsonReqObject(requestUrl, wxMessage, headers)); 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