parent
b0aaa698f6
commit
60326d842d
@ -0,0 +1,75 @@ |
|||||||
|
package com.cweb.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
import com.github.pagehelper.PageInfo; |
||||||
|
import com.hai.common.exception.ErrorCode; |
||||||
|
import com.hai.common.exception.ErrorHelp; |
||||||
|
import com.hai.common.exception.SysCode; |
||||||
|
import com.hai.common.security.SessionObject; |
||||||
|
import com.hai.common.security.UserCenter; |
||||||
|
import com.hai.common.utils.*; |
||||||
|
import com.hai.entity.*; |
||||||
|
import com.hai.model.HighUserModel; |
||||||
|
import com.hai.model.ResponseData; |
||||||
|
import com.hai.service.*; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: |
||||||
|
* @Date: 2021/3/26 23:08 |
||||||
|
*/ |
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/test") |
||||||
|
@Api(value = "订单接口") |
||||||
|
public class HighTestController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(HighTestController.class); |
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/getOrderById", method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "根据id查询订单详情") |
||||||
|
public ResponseData getOrderById() { |
||||||
|
try { |
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("app_key", "208241666939552"); |
||||||
|
//map.put("app_secret", "adecc3cff077834cb8632c8ab3bec0e6");
|
||||||
|
map.put("timestamp", new Date().getTime()); |
||||||
|
map.put("pageIndex", 1); |
||||||
|
map.put("pageSize", 10); |
||||||
|
String signStr = "adecc3cff077834cb8632c8ab3bec0e6" + WxUtils.generateSignature(map,"adecc3cff077834cb8632c8ab3bec0e6") + "adecc3cff077834cb8632c8ab3bec0e6"; |
||||||
|
|
||||||
|
System.out.println("加密前:" + signStr); |
||||||
|
String sign = MD5Util.encode(signStr.getBytes()).toLowerCase(); |
||||||
|
System.out.println("加密后:" + sign); |
||||||
|
map.put("sign", sign); |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(HttpsUtils.doPost("https://test02-motorcade-hcs.czb365.com/services/vp/openapi/queryGasInfoListByPage", JSON.toJSONString(map))); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighOrderController --> getOrderById() error!", e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
package com.hai.service.pay.impl; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hai.common.exception.ErrorCode; |
||||||
|
import com.hai.common.exception.ErrorHelp; |
||||||
|
import com.hai.common.exception.SysCode; |
||||||
|
import com.hai.common.pay.util.XmlUtil; |
||||||
|
import com.hai.common.pay.util.sdk.WXPayConstants; |
||||||
|
import com.hai.common.utils.WxUtils; |
||||||
|
import com.hai.dao.HighUserCouponMapper; |
||||||
|
import com.hai.entity.*; |
||||||
|
import com.hai.model.ResultProfitSharing; |
||||||
|
import com.hai.service.*; |
||||||
|
import com.hai.service.pay.PayService; |
||||||
|
import org.apache.http.HttpEntity; |
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse; |
||||||
|
import org.apache.http.client.methods.HttpPost; |
||||||
|
import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
||||||
|
import org.apache.http.entity.StringEntity; |
||||||
|
import org.apache.http.impl.client.CloseableHttpClient; |
||||||
|
import org.apache.http.impl.client.HttpClients; |
||||||
|
import org.apache.http.ssl.SSLContexts; |
||||||
|
import org.apache.http.util.EntityUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
import org.springframework.transaction.annotation.Propagation; |
||||||
|
import org.springframework.transaction.annotation.Transactional; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.net.ssl.SSLContext; |
||||||
|
import java.io.FileInputStream; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.security.KeyStore; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: |
||||||
|
* @Date: 2021/3/27 00:35 |
||||||
|
*/ |
||||||
|
@Service("rechargeOrderService") |
||||||
|
public class rechargeOrderServiceImpl implements PayService { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(rechargeOrderServiceImpl.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private OutRechargeOrderService outRechargeOrderService; |
||||||
|
|
||||||
|
@Override |
||||||
|
@Transactional(propagation= Propagation.REQUIRES_NEW) |
||||||
|
public void paySuccess(Map<String, String> map, String payType) throws Exception { |
||||||
|
if (payType.equals("Alipay")) { |
||||||
|
// 支付宝支付 todo 暂未开发
|
||||||
|
return; |
||||||
|
} |
||||||
|
if (payType.equals("WechatPay")) { |
||||||
|
// 查询订单信息
|
||||||
|
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(map.get("out_trade_no")); |
||||||
|
if (order == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); |
||||||
|
} |
||||||
|
if (order.getOrderStatus() == 1) { |
||||||
|
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
|
||||||
|
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
|
||||||
|
order.setPayTime(new Date()); // 支付时间
|
||||||
|
order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
|
||||||
|
outRechargeOrderService.updateOrder(order); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
Binary file not shown.
Loading…
Reference in new issue