From c5c4f201eedfcf374008238dce7afc84f8200ea4 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期六, 07 二月 2026 16:33:42 +0800
Subject: [PATCH] 代码初始化
---
server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java | 191 +++++++++++++++++++----------------------------
1 files changed, 77 insertions(+), 114 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
index 9f9db40..bdacd23 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/OrdersServiceImpl.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
+import com.allinpay.syb.lib.DoumeeTLUtil;
import com.allinpay.syb.lib.SybConstants;
import com.allinpay.syb.lib.SybUtil;
import com.allinpay.syb.model.PayPublicModel;
@@ -18,9 +19,11 @@
import com.allinpay.syb.model.PayOrderNotifyParam;
import com.allinpay.syb.model.PayOrderParam;
import com.allinpay.syb.model.PayOrderResponse;
+import com.doumee.dao.business.RefundMapper;
import com.doumee.dao.business.model.Orders;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.OrdersMapper;
+import com.doumee.dao.business.model.Refund;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.dao.vo.IndexOrderCountVO;
@@ -56,6 +59,8 @@
@Autowired
private OrdersMapper ordersMapper;
+ @Autowired
+ private RefundMapper refundMapper;
@Autowired
private SystemUserMapper systemUserMapper;
@Autowired
@@ -207,6 +212,7 @@
IPage<Orders> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
MPJLambdaWrapper<Orders> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(Orders.class)
+ .select("(select sum(r.money) from refund r where r.deleted=0 and r.status in(0,1) and r.order_id=t.id)",Orders::getRefundMoney)
.selectAs(SystemUser::getRealname,Orders::getUserRealname)
.selectAs(SystemUser::getUsername,Orders::getUsername)
.leftJoin(SystemUser.class,SystemUser::getId,Orders::getUserId);
@@ -357,7 +363,7 @@
.eq(Orders::getStatus,Constants.ZERO)
.apply("TIMESTAMPDIFF(MINUTE, create_time ,now()) > "+time));
if(orderList !=null && orderList.size()>0){
- PayPublicModel publicModel = initPayPublicModel();
+ PayPublicModel publicModel =systemDictDataBiz.initPayPublicModel();
Date date = new Date();
for(Orders model : orderList){
queryPayOrderDetailBiz(model,publicModel,date,time);
@@ -373,26 +379,15 @@
}
Orders model = ordersMapper.selectById(param.getId());
if(model !=null ){
- PayPublicModel publicModel = initPayPublicModel();
+ PayPublicModel publicModel =systemDictDataBiz.initPayPublicModel();
Date date = new Date();
queryPayOrderDetailBiz(model,publicModel,date,time);
}
}
private void queryPayOrderDetailBiz(Orders model, PayPublicModel publicModel, Date date,int time) {
- TreeMap<String,String> params = new TreeMap<String,String>();
- params.put("cusid",publicModel.getCusid());
- params.put("appid",publicModel.getAppid());
- params.put("version",publicModel.getVersion());
- params.put("trxid", "");
- params.put("randomstr", SybUtil.getValidatecode(8));
- params.put("signtype", publicModel.getSigntype());
- String appkey = publicModel.getAppkey();
- String url = publicModel.getUrl();
- String appPubkey = publicModel.getAppPubkey();
- params.remove("sign");
- params.put("reqsn", model.getId()+"");
- PayOrderNotifyParam map = query(params,url,appkey,appPubkey);
+ DoumeeTLUtil doumeeTLUtil = new DoumeeTLUtil(publicModel);
+ PayOrderNotifyParam map = doumeeTLUtil.sendQueryOrder(model.getId()+"");
int status = Constants.TWO;
if(map!=null){
String info = SybUtil.getPayInfoByStatus(map);
@@ -406,7 +401,7 @@
status = Constants.ONE;
} else if (StringUtils.equals(map.getTrxstatus(),"2000") || StringUtils.equals(map.getTrxstatus(),"2008")) {
//濡傛灉浜ゆ槗鏈敮浠橈紝骞朵笖鏈秴杩囧崐灏忔椂锛屼笉澶勭悊
- if(date.getTime() - model.getCreateTime().getTime() < 30*60*1000){
+ if(date.getTime() - model.getCreateTime().getTime() < time*60*1000){
return;
}
}
@@ -429,66 +424,8 @@
ordersMapper.updateById(model) ;
}
- private PayPublicModel initPayPublicModel() {
- PayPublicModel model = new PayPublicModel();
- model.setUrl(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_SYB_CUSID).getCode());
- model.setCusid( systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_SYB_CUSID).getCode());
- model.setAppid(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_SYB_APPID).getCode());
- model.setVersion(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_VERSION).getCode());
- model.setSigntype( systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_SIGN_TYPE).getCode());
- model.setAppkey(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_APPKEY).getCode());
- model.setUrl(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_SYB_APIURL).getCode());
- model.setAppPubkey( systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_SYB_RSATLPUBKEY).getCode());
- return model;
- }
- public PayOrderNotifyParam query( TreeMap<String,String> params,String url,String appkey,String pubKey ) {
- try {
- params.put("sign", SybUtil.unionSign(params,appkey,SybConstants.SIGN_TYPE));
- String data =getHttpParamsStr(params);
- log.error("璁㈠崟鏌ヨ鏁版嵁璇锋眰================{}",data);
- String result = HttpsUtil.post(url+"/tranx/query",data,"application/x-www-form-urlencoded",true);
- log.error("璁㈠崟鏌ヨ鏁版嵁杩斿洖================{}",result);
- PayOrderNotifyParam map = handleResult(result,pubKey,params.get("signtype"));
- return map;
- }catch (Exception e){
- log.error("閫氳仈璁㈠崟鏌ヨ寮傚父================{}",e);
- }
- return null;
- }
- public String getHttpParamsStr(Map<String, String> params ) throws IOException {
- StringBuilder outBuf = new StringBuilder();
- boolean isNotFirst = false;
- for (Map.Entry<String, String> entry: params.entrySet()){
- if (isNotFirst)
- outBuf.append('&');
- isNotFirst = true;
- outBuf
- .append(entry.getKey())
- .append('=')
- .append(URLEncoder.encode(entry.getValue(), "UTF-8"));
- }
- System.out.println("鍙傛暟:"+outBuf.toString());
- return outBuf.toString();
- }
- public static PayOrderNotifyParam handleResult(String result,String pubKey,String signType) throws Exception{
- log.error("杩斿洖鏁版嵁杩斿洖================{}",result);
- Map map = SybUtil.json2ObjMap(result);
- if(map == null){
- log.error("杩斿洖鏁版嵁杩斿洖閿欒================{}",result);
- throw new Exception("杩斿洖鏁版嵁閿欒");
- }
- if("SUCCESS".equals(map.get("retcode"))){
- TreeMap tmap = new TreeMap();
- tmap.putAll(map);
- if(SybUtil.validSign(tmap, pubKey, signType)){
- PayOrderNotifyParam param = JSONObject.toJavaObject(JSONObject.parseObject(result),PayOrderNotifyParam.class);
- return param;
- }
- }
- return null;
- }
@Override
public void returnPage(PayOrderParam param, HttpServletResponse response) throws IOException {
// String url =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PAY_RETURN_WEB_URL).getCode();
@@ -512,46 +449,24 @@
r ="鏀粯缁撴灉寮傚父锛屽鏈夌枒闂鑱旂郴瀹㈡湇浜哄憳";
return;
}
- Orders model = ordersMapper.selectOne(new QueryWrapper<Orders>().lambda()
- .eq(Orders::getId,Integer.parseInt(map.getCusorderid()))
- );
- if(model ==null){
- log.error("鏀粯澶勭悊澶辫触======鏈壘鍒颁氦鏄撹鍗�"+map.getCusorderid());
- r ="鏀粯缁撴灉寮傚父锛岃鍗曟煡璇㈠け璐ワ紝濡傛湁鐤戦棶璇疯仈绯诲鏈嶄汉鍛�";
- return;
- }
- if(Constants.equalsInteger(model.getPayStatus(),Constants.ONE)){
- log.error("鏀粯澶勭悊======璁㈠崟宸叉敮浠�"+map.getCusorderid());
- return;
- }
String info = SybUtil.getPayInfoByStatus(map);
if(StringUtils.equals(map.getTrxcode(),"VSP501")
||StringUtils.equals(map.getTrxcode(),"VSP511")
||StringUtils.equals(map.getTrxcode(),"VSP551")){
//浜ゆ槗绫诲瀷鏄� 寰俊鏀粯 銆佹敮浠樺疂鏀粯鎴栬�呴摱鑱旀壂鐮佹敮浠橈紝璁板綍鏀粯鐘舵��
- if(StringUtils.equals(map.getTrxstatus(),"0000")){
- //浜ゆ槗鎴愬姛
- model.setPayStatus(Constants.ONE);
- model.setStatus(Constants.ONE);
- }else{
- //浜ゆ槗澶辫触
- model.setStatus(Constants.TWO);
- }
- }else{
- model.setStatus(Constants.TWO);
+ dealOrdersResultBiz(info,map,r);
+ }else if(StringUtils.equals(map.getTrxcode(),"VSP503")
+ ||StringUtils.equals(map.getTrxcode(),"VSP513")
+ ||StringUtils.equals(map.getTrxcode(),"VSP553")){
+ //浜ゆ槗绫诲瀷鏄� 寰俊t閫�娆� 銆佹敮浠樺疂鏀粯閫�娆炬垨鑰呴摱鑱旀壂鐮侀��璐э紝璁板綍鏀粯鐘舵��
+ dealRefunResultBiz(info,map,r);//澶勭悊閫�娆�
+ }else {
+ //鍏朵粬绫诲瀷涓嶉�氱煡
}
- model.setPayFee(map.getFee());
- model.setPayDate(DateUtil.fromStringToDate("yyyyMMddHHmmss",map.getPaytime()));
- model.setPayOrderId(map.getSrctrxid());//閫氳仈璁㈠崟鍙�
- model.setPayThirdOrderId(map.getChnltrxid());//鏀粯瀹濆井淇¤鍗曞彿
- model.setPayThirdOrderData(map.getChnldata());//涓夋柟浜ゆ槗娓犻亾鏁版嵁
- model.setPayInfo(info);
- model.setPayCode(map.getTrxcode());
- ordersMapper.updateById(model);
+
}else{
log.error("鏀粯楠岀澶辫触======");
r ="鏀粯澶辫触锛屽鏈夌枒闂鑱旂郴瀹㈡湇浜哄憳";
- return;
}
//楠岀瀹屾瘯杩涜涓氬姟澶勭悊
} catch (Exception e) {//澶勭悊寮傚父
@@ -565,18 +480,66 @@
}
}
-
- public TreeMap<String, String> getParams(HttpServletRequest request){
- TreeMap<String, String> map = new TreeMap<String, String>();
- Map reqMap = request.getParameterMap();
- for(Object key:reqMap.keySet()){
- String value = ((String[])reqMap.get(key))[0];
- System.out.println(key+";"+value);
- map.put(key.toString(),value);
+ private String dealRefunResultBiz(String info, PayOrderNotifyParam map, String r) {
+ Refund model = refundMapper.selectOne(new QueryWrapper<Refund>().lambda()
+ .eq(Refund::getId,Integer.parseInt(map.getCusorderid().replace(DoumeeTLUtil.REFUND_SN_PREFIX,"")))
+ );
+ if(model ==null){
+ log.error("鏀粯澶勭悊澶辫触======鏈壘鍒颁氦鏄撹鍗�"+map.getCusorderid());
+ return "鏀粯缁撴灉寮傚父锛岃鍗曟煡璇㈠け璐ワ紝濡傛湁鐤戦棶璇疯仈绯诲鏈嶄汉鍛�";
}
- return map;
+ if(Constants.equalsInteger(model.getStatus(),Constants.ONE)){
+ log.error("鏀粯澶勭悊======璁㈠崟宸叉敮浠�"+map.getCusorderid());
+ return "璁㈠崟宸叉敮浠�";
+ }
+ if(StringUtils.equals(map.getTrxstatus(),"0000")){
+ //浜ゆ槗鎴愬姛
+ model.setStatus(Constants.ONE);
+ }else{
+ //浜ゆ槗澶辫触
+ model.setStatus(Constants.TWO);
+ }
+ model.setPayFee(map.getFee());
+ model.setPayDate(DateUtil.fromStringToDate("yyyyMMddHHmmss",map.getPaytime()));
+ model.setPayOrderId(map.getTrxid());//閫氳仈璁㈠崟鍙�
+ model.setPayThirdOrderId(map.getChnltrxid());//鏀粯瀹濆井淇¤鍗曞彿
+ model.setPayThirdOrderData(map.getChnldata());//涓夋柟浜ゆ槗娓犻亾鏁版嵁
+ model.setPayInfo(info);
+ model.setPayCode(map.getTrxcode());
+ refundMapper.updateById(model);
+ return r;
}
+ private String dealOrdersResultBiz(String info, PayOrderNotifyParam map,String r) {
+ Orders model = ordersMapper.selectOne(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getId,Integer.parseInt(map.getCusorderid()))
+ );
+ if(model ==null){
+ log.error("鏀粯澶勭悊澶辫触======鏈壘鍒颁氦鏄撹鍗�"+map.getCusorderid());
+ return "鏀粯缁撴灉寮傚父锛岃鍗曟煡璇㈠け璐ワ紝濡傛湁鐤戦棶璇疯仈绯诲鏈嶄汉鍛�";
+ }
+ if(Constants.equalsInteger(model.getPayStatus(),Constants.ONE)){
+ log.error("鏀粯澶勭悊======璁㈠崟宸叉敮浠�"+map.getCusorderid());
+ return "璁㈠崟宸叉敮浠�";
+ }
+ if(StringUtils.equals(map.getTrxstatus(),"0000")){
+ //浜ゆ槗鎴愬姛
+ model.setPayStatus(Constants.ONE);
+ model.setStatus(Constants.ONE);
+ }else{
+ //浜ゆ槗澶辫触
+ model.setStatus(Constants.TWO);
+ }
+ model.setPayFee(map.getFee());
+ model.setPayDate(DateUtil.fromStringToDate("yyyyMMddHHmmss",map.getPaytime()));
+ model.setPayOrderId(map.getTrxid());//閫氳仈璁㈠崟鍙�
+ model.setPayThirdOrderId(map.getChnltrxid());//鏀粯瀹濆井淇¤鍗曞彿
+ model.setPayThirdOrderData(map.getChnldata());//涓夋柟浜ゆ槗娓犻亾鏁版嵁
+ model.setPayInfo(info);
+ model.setPayCode(map.getTrxcode());
+ ordersMapper.updateById(model);
+ return r;
+ }
}
--
Gitblit v1.9.3