master
parent
242b68578a
commit
09d6a4c99d
@ -0,0 +1,83 @@ |
|||||||
|
package com.order.controller.business; |
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
import com.github.pagehelper.PageInfo; |
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
import com.hfkj.service.coupon.BsOrderCouponService; |
||||||
|
import com.order.controller.OrderController; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: OrderCouponController |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/5/11 |
||||||
|
**/ |
||||||
|
@Controller |
||||||
|
@RequestMapping(value="/coupon") |
||||||
|
@Api(value="卡券订单业务") |
||||||
|
public class OrderCouponController { |
||||||
|
Logger log = LoggerFactory.getLogger(OrderCouponController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsOrderCouponService orderCouponService; |
||||||
|
|
||||||
|
@RequestMapping(value="/queryList",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "查询交易订单列表") |
||||||
|
public ResponseData queryList(@RequestParam(value = "orderNo" , required = false) String orderNo, |
||||||
|
@RequestParam(value = "childOrderNo" , required = false) String childOrderNo, |
||||||
|
@RequestParam(value = "merId" , required = false) Long merId, |
||||||
|
@RequestParam(value = "userPhone" , required = false) String userPhone, |
||||||
|
@RequestParam(value = "payChannel" , required = false) Integer payChannel, |
||||||
|
@RequestParam(value = "payType" , required = false) Integer payType, |
||||||
|
@RequestParam(value = "createTimeS" , required = false) Long createTimeS, |
||||||
|
@RequestParam(value = "createTimeE" , required = false) Long createTimeE, |
||||||
|
@RequestParam(value = "payTimeS" , required = false) Long payTimeS, |
||||||
|
@RequestParam(value = "payTimeE" , required = false) Long payTimeE, |
||||||
|
@RequestParam(value = "finishTimeS" , required = false) Long finishTimeS, |
||||||
|
@RequestParam(value = "finishTimeE" , required = false) Long finishTimeE, |
||||||
|
@RequestParam(value = "cancelTimeS" , required = false) Long cancelTimeS, |
||||||
|
@RequestParam(value = "cancelTimeE" , required = false) Long cancelTimeE, |
||||||
|
@RequestParam(value = "pageNum" , required = true) Integer pageNum, |
||||||
|
@RequestParam(value = "pageSize" , required = true) Integer pageSize) { |
||||||
|
try { |
||||||
|
Map<String,Object> param = new HashMap<>(); |
||||||
|
param.put("orderNo", orderNo); |
||||||
|
param.put("userPhone", userPhone); |
||||||
|
param.put("payChannel", payChannel); |
||||||
|
param.put("payType", payType); |
||||||
|
param.put("createTimeS", createTimeS); |
||||||
|
param.put("createTimeE", createTimeE); |
||||||
|
param.put("payTimeS", payTimeS); |
||||||
|
param.put("payTimeE", payTimeE); |
||||||
|
param.put("finishTimeS", finishTimeS); |
||||||
|
param.put("finishTimeE", finishTimeE); |
||||||
|
param.put("cancelTimeS", cancelTimeS); |
||||||
|
param.put("cancelTimeE", cancelTimeE); |
||||||
|
|
||||||
|
PageHelper.startPage(pageNum, pageSize); |
||||||
|
return ResponseMsgUtil.success(new PageInfo<>()); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,126 @@ |
|||||||
|
package com.hfkj.common.utils; |
||||||
|
|
||||||
|
import javax.crypto.Cipher; |
||||||
|
import javax.crypto.spec.SecretKeySpec; |
||||||
|
import java.util.Calendar; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: AESTool |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2022/9/27 |
||||||
|
**/ |
||||||
|
public class AESTool { |
||||||
|
|
||||||
|
public static String Encrypt(String sSrc, String sKey) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
return toHex(encryptBytes(sSrc.getBytes("utf-8"), sKey)); |
||||||
|
} catch (Exception ex) { |
||||||
|
throw new RuntimeException(ex.toString()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static byte[] encrypt(byte[] sSrc, String sKey) { |
||||||
|
try { |
||||||
|
return encryptBytes(sSrc, sKey); |
||||||
|
} catch (Exception ex) { |
||||||
|
throw new RuntimeException(ex.toString()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static byte[] encryptBytes(byte[] sSrc, String sKey) throws Exception |
||||||
|
{ |
||||||
|
if (sKey == null) { |
||||||
|
throw new Exception("Key为空null"); |
||||||
|
} |
||||||
|
|
||||||
|
if (sKey.length() != 16) { |
||||||
|
throw new Exception("Key长度不是16位"); |
||||||
|
} |
||||||
|
byte[] raw = sKey.getBytes("utf-8"); |
||||||
|
|
||||||
|
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); |
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); |
||||||
|
cipher.init(1, skeySpec); |
||||||
|
byte[] encrypted = cipher.doFinal(sSrc); |
||||||
|
return encrypted; |
||||||
|
} |
||||||
|
|
||||||
|
public static String Decrypt(String sSrc, String sKey) |
||||||
|
{ |
||||||
|
try { |
||||||
|
return new String(decryptBytes(toBytes(sSrc), sKey), "utf-8"); |
||||||
|
} catch (Exception ex) { |
||||||
|
throw new RuntimeException(ex.toString()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static byte[] decrypt(byte[] sSrc, String sKey) { |
||||||
|
try { |
||||||
|
return decryptBytes(sSrc, sKey); |
||||||
|
} catch (Exception ex) { |
||||||
|
throw new RuntimeException(ex.toString()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static byte[] decryptBytes(byte[] sSrc, String sKey) |
||||||
|
throws Exception |
||||||
|
{ |
||||||
|
if (sKey == null) { |
||||||
|
throw new Exception("Key为空null"); |
||||||
|
} |
||||||
|
|
||||||
|
if (sKey.length() != 16) { |
||||||
|
throw new Exception("Key长度不是16位"); |
||||||
|
} |
||||||
|
byte[] raw = sKey.getBytes("utf-8"); |
||||||
|
|
||||||
|
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); |
||||||
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); |
||||||
|
cipher.init(2, skeySpec); |
||||||
|
byte[] original = cipher.doFinal(sSrc); |
||||||
|
return original; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static String toHex(byte[] buf) |
||||||
|
{ |
||||||
|
if (buf == null) |
||||||
|
return ""; |
||||||
|
StringBuffer result = new StringBuffer(2 * buf.length); |
||||||
|
for (int i = 0; i < buf.length; i++) { |
||||||
|
appendHex(result, buf[i]); |
||||||
|
} |
||||||
|
return result.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
private static void appendHex(StringBuffer sb, byte b) { |
||||||
|
sb.append("0123456789ABCDEF".charAt(b >> 4 & 0xF)).append("0123456789ABCDEF".charAt(b & 0xF)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static byte[] toBytes(String hexString) |
||||||
|
{ |
||||||
|
int len = hexString.length() / 2; |
||||||
|
byte[] result = new byte[len]; |
||||||
|
for (int i = 0; i < len; i++) |
||||||
|
result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), |
||||||
|
16).byteValue(); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
Calendar cal = Calendar.getInstance(); |
||||||
|
cal.add(5, 10); |
||||||
|
String str = "1,13439676580," + cal.getTimeInMillis(); |
||||||
|
String key = "0123456789ABCDEF"; |
||||||
|
String token = Encrypt(str, key); |
||||||
|
System.out.println(token); |
||||||
|
System.out.println(Decrypt(token, key)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package com.hfkj.service.coupon; |
||||||
|
|
||||||
|
import com.hfkj.entity.BsOrderCouponNo; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: BsOrderCouponNoService |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/5/11 |
||||||
|
**/ |
||||||
|
public interface BsOrderCouponNoService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑数据 |
||||||
|
* @param data |
||||||
|
*/ |
||||||
|
void editData(BsOrderCouponNo data); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询列表 |
||||||
|
* @param couponOrderNo |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<BsOrderCouponNo> getListByCouponOrderId(Long couponOrderId); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package com.hfkj.service.coupon; |
||||||
|
|
||||||
|
import com.hfkj.entity.BsOrderCoupon; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 卡券订单业务 |
||||||
|
* @className: BsOrderCouponService |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/5/10 |
||||||
|
**/ |
||||||
|
public interface BsOrderCouponService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 编辑数据 |
||||||
|
* @param data |
||||||
|
*/ |
||||||
|
void editData(BsOrderCoupon data); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询卡券订单 |
||||||
|
* @param orderChildOrderNo 子订单号 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<BsOrderCoupon> getListByChildOrderNo(String orderChildOrderNo); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,340 @@ |
|||||||
|
package com.hfkj.service.coupon.channel; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import com.hfkj.common.utils.RedisUtil; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 比邻星业务 |
||||||
|
*/ |
||||||
|
@Component |
||||||
|
public class BlxCouponService { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(BlxCouponService.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private RedisUtil redisUtil; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name generateJw |
||||||
|
* @Description // 获取token
|
||||||
|
* @Date 10:42 2023/7/11 |
||||||
|
* @Param [] |
||||||
|
* @Return java.lang.String |
||||||
|
*/ |
||||||
|
public String generateJw() { |
||||||
|
|
||||||
|
Object token = redisUtil.get("BlxToken"); |
||||||
|
|
||||||
|
if (token == null) { |
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("organizeCode" , "dhy"); |
||||||
|
log.info("============ 比邻星停车券业务-获取TOKEN-START ============="); |
||||||
|
JSONObject object = HttpsUtils.doGet(CommonSysConst.getSysConfig().getBlxPostUrl() + "/admin/api/generateJwt" , map); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + object); |
||||||
|
log.info("============ 比邻星停车券业务-获取TOKEN-END =============="); |
||||||
|
redisUtil.set("BlxToken" , object.getString("data") , 2000); |
||||||
|
return object.getString("data"); |
||||||
|
} |
||||||
|
|
||||||
|
return token.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name queryCouponPage |
||||||
|
* @Description // 获取比邻星停车券列表
|
||||||
|
* @Date 10:57 2023/7/11 |
||||||
|
* @Param [] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject queryCouponPage() { |
||||||
|
log.info("============ 比邻星停车券业务-获取比邻星停车券列表-START ============="); |
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("rows" , "20"); |
||||||
|
map.put("currPage" , "1"); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
|
||||||
|
JSONObject object = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/admin/api/qureyCouponPage" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + object); |
||||||
|
log.info("============ 比邻星停车券业务-获取比邻星停车券列表-END =============="); |
||||||
|
return object; |
||||||
|
|
||||||
|
} |
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name sendCoupon |
||||||
|
* @Description // 发放券
|
||||||
|
* @Date 11:01 2023/7/11 |
||||||
|
* @Param [object] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject sendCoupon(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("couponCode" , object.getString("couponCode")); |
||||||
|
map.put("receiverPhone" , object.getString("receiverPhone")); |
||||||
|
map.put("receiverCount" , object.getInteger("receiverCount")); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
log.info("============ 比邻星停车券业务-发放停车券-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/admin/api/sendCupon" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-发放停车券-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name queryCouponPage |
||||||
|
* @Description // 获取比邻星停车券列表
|
||||||
|
* @Date 10:57 2023/7/11 |
||||||
|
* @Param [] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject getUserCouponPage(JSONObject object) { |
||||||
|
log.info("============ 比邻星停车券业务-获取用户未使用卡券列表-START ============="); |
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("rows" , "2000"); |
||||||
|
map.put("currPage" , "1"); |
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject(); |
||||||
|
|
||||||
|
jsonObject.put("userMobile" , object.getString("userMobile")); |
||||||
|
jsonObject.put("couponStatus" , object.getInteger("couponStatus")); |
||||||
|
map.put("data" , jsonObject); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
|
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/admin/api/getUserCouponPage" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-获取比邻星停车券列表-END =============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getUserBindCarNo |
||||||
|
* @Description // 获取用户绑定车辆信息
|
||||||
|
* @Date 10:11 2023/8/25 |
||||||
|
* @Param [object] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject getUserBindCarNo(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("userMobile" , object.getString("userMobile")); |
||||||
|
map.put("organizeCode" , object.getString("organizeCode")); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
log.info("============ 比邻星停车券业务-获取用户绑定车辆信息-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/getUserBindCarNo" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-获取用户绑定车辆信息-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name addUserBindCarNo |
||||||
|
* @Description // 用户绑定车辆
|
||||||
|
* @Date 10:11 2023/8/25 |
||||||
|
* @Param [object] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject addUserBindCarNo(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("userMobile" , object.getString("userMobile")); |
||||||
|
map.put("organizeCode" , object.getString("organizeCode")); |
||||||
|
map.put("plateNumber" , object.getString("plateNumber")); |
||||||
|
// 车牌颜色- 0:未知,1:蓝色,2:黄色,3:黑色,4:白色,5:绿色
|
||||||
|
map.put("plateColor" , object.getString("plateColor")); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
log.info("============ 比邻星停车券业务-用户绑定车辆-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/addUserBindCarNo" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-用户绑定车辆-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name delUserBindCarNo |
||||||
|
* @Description // 删除用户绑定车辆
|
||||||
|
* @Date 10:20 2023/8/25 |
||||||
|
* @Param [object] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject delUserBindCarNo(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("userMobile" , object.getString("userMobile")); |
||||||
|
map.put("organizeCode" , object.getString("organizeCode")); |
||||||
|
map.put("plateNumber" , object.getString("plateNumber")); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
log.info("============ 比邻星停车券业务-删除用户绑定车辆-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/delUserBindCarNo" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-删除用户绑定车辆-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name queryJsParking |
||||||
|
* @Description // 获取附近停车场-捷顺
|
||||||
|
* @Date 10:26 2023/8/25 |
||||||
|
* @Param [object] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject queryJsParking(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("gps" , object.getString("gps")); |
||||||
|
map.put("range" , object.getString("range")); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
log.info("============ 比邻星停车券业务-获取附近停车场-捷顺-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/queryJsParking" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-获取附近停车场-捷顺-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name queryJsOrderList |
||||||
|
* @Description // 查询车牌订单列表信息
|
||||||
|
* @Date 11:42 2023/8/28 |
||||||
|
* @Param [object] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject queryJsOrderList(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("carNo" , object.getString("carNo")); |
||||||
|
map.put("orderStatus" , object.getString("orderStatus")); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/queryJsOrderList" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
System.out.println(header); |
||||||
|
System.out.println(map); |
||||||
|
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name creatOrder |
||||||
|
* @Description // 停车添加订单
|
||||||
|
* @Date 10:12 2023/8/30 |
||||||
|
* @Param [object] |
||||||
|
* @Return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject creatOrder(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , Object > map = new HashMap<>(); |
||||||
|
map.put("organizeCode" , "dhy"); |
||||||
|
map.put("userMobile" , object.getString("userMobile")); |
||||||
|
map.put("userCouponCode" , object.getString("userCouponCode")); |
||||||
|
map.put("parkOrderId" , object.getString("parkOrderId")); |
||||||
|
map.put("orderType" , object.getString("orderType")); |
||||||
|
map.put("prePrice" , object.getString("prePrice")); |
||||||
|
map.put("parkId" , object.getString("parkId")); |
||||||
|
map.put("parkName" , object.getString("parkName")); |
||||||
|
map.put("parkTime" , object.getString("parkTime")); |
||||||
|
map.put("carSeatId" , object.getString("carSeatId")); |
||||||
|
map.put("inTime" , object.getString("inTime")); |
||||||
|
map.put("outTime" , object.getString("outTime")); |
||||||
|
map.put("carNo" , object.getString("carNo")); |
||||||
|
map.put("parkType" , 1); |
||||||
|
|
||||||
|
Map<String , Object> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doPost(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/creatOrder" , map , header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-查询车牌订单列表信息--捷顺-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name parkOrderPay |
||||||
|
* @Description // 订单支付
|
||||||
|
* @Date 14:49 2023/9/4 |
||||||
|
* @Param object |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public JSONObject parkOrderPay(JSONObject object) { |
||||||
|
|
||||||
|
Map<String , String> header = new HashMap<>(); |
||||||
|
header.put("token" , generateJw()); |
||||||
|
Map<String , String> map = new HashMap<>(); |
||||||
|
map.put("orderCode" , object.getString("orderCode")); |
||||||
|
log.info("============ 比邻星停车券业务-停车场订单支付--捷顺-START ============="); |
||||||
|
JSONObject data = HttpsUtils.doGet(CommonSysConst.getSysConfig().getBlxPostUrl() + "/peration/member/parking/api/parkOrderPay" , map, header); |
||||||
|
log.info("头部参数: " + header); |
||||||
|
log.info("请求参数: " + map); |
||||||
|
log.info("响应参数: " + data); |
||||||
|
log.info("============ 比邻星停车券业务-停车场订单支付--捷顺-END ============="); |
||||||
|
return data; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,165 @@ |
|||||||
|
package com.hfkj.service.coupon.channel; |
||||||
|
|
||||||
|
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.AESTool; |
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import com.hfkj.common.utils.MD5Util; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Random; |
||||||
|
|
||||||
|
/** |
||||||
|
* 重庆中石油卡券 |
||||||
|
* @className: CqPetroChina |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2022/9/26 |
||||||
|
**/ |
||||||
|
public class ChongQingCNPCCouponService { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(ChongQingCNPCCouponService.class); |
||||||
|
|
||||||
|
/** |
||||||
|
* 电子券预发放接口 |
||||||
|
* @param requestCode |
||||||
|
* @param tradeId |
||||||
|
* @param ticketSum |
||||||
|
* @param phone |
||||||
|
*/ |
||||||
|
public static JSONObject preSendCoupon(String requestCode, String tradeId, Integer ticketSum, String phone) throws Exception { |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put("requestCode", requestCode); |
||||||
|
map.put("tradeId", tradeId); |
||||||
|
map.put("ticketSum", ticketSum); |
||||||
|
map.put("phone", phone); |
||||||
|
return request("preSendCoupon", map); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 发放电子券 |
||||||
|
* @param requestCode |
||||||
|
* @param tradeId |
||||||
|
* @param ticketSum |
||||||
|
* @param phone |
||||||
|
*/ |
||||||
|
public static JSONObject sendCNPCTicket(String requestCode, String tradeId, Integer ticketSum, String phone) throws Exception { |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put("requestCode", requestCode); |
||||||
|
map.put("tradeId", tradeId); |
||||||
|
map.put("ticketSum", ticketSum); |
||||||
|
map.put("phone", phone); |
||||||
|
return request("sendCNPCTicket", map); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 电子券作废 |
||||||
|
* @param couponNo 电子券编号 |
||||||
|
* @param random 随机数 |
||||||
|
*/ |
||||||
|
public static JSONObject invalidCoupon(String couponNo, String random) throws Exception { |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put("couponNo", couponNo); |
||||||
|
map.put("random", random); |
||||||
|
return request("invalidCoupon", map); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取中石油跨界券核销码 |
||||||
|
* @param couponNo |
||||||
|
* @param tradeId |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static JSONObject getCNPCCheckCode(String couponNo, String tradeId) throws Exception { |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put("couponNo", couponNo); |
||||||
|
map.put("tradeId", tradeId); |
||||||
|
return request("getCNPCCheckCode", map); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取电子券详情 |
||||||
|
* @param couponNo |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static JSONObject queryCoupon(String couponNo) throws Exception { |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put("couponNo", couponNo); |
||||||
|
map.put("random", String.valueOf(new Random().nextInt(899999) + 100000)); |
||||||
|
return request("queryCoupon", map); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 请求 |
||||||
|
* @param actionType 接口类型 |
||||||
|
* @param param 参数 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject request(String actionType, Map<String,Object> param) throws Exception { |
||||||
|
String verifyCode = AESTool.Encrypt(JSONObject.toJSONString(param), CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); |
||||||
|
|
||||||
|
JSONObject header = new JSONObject(); |
||||||
|
header.put("strVendorCode", CommonSysConst.getSysConfig().getChongQingCnpcMerNo()); |
||||||
|
header.put("strActionType", actionType); |
||||||
|
header.put("verifyCode", MD5Util.encode((verifyCode + CommonSysConst.getSysConfig().getChongQingCnpcMerKey()).getBytes()).toLowerCase()); |
||||||
|
|
||||||
|
JSONObject msg = new JSONObject(); |
||||||
|
msg.put("head", header); |
||||||
|
msg.put("body", verifyCode); |
||||||
|
|
||||||
|
Map<String, Object> reqParam = new HashMap<>(); |
||||||
|
reqParam.put("sendMessage", msg); |
||||||
|
|
||||||
|
log.info("============start============"); |
||||||
|
log.info("请求接口:" + actionType); |
||||||
|
log.info("参数:" + JSONObject.toJSONString(param)); |
||||||
|
log.info("请求参数:" + JSONObject.toJSONString(reqParam)); |
||||||
|
JSONObject response = HttpsUtils.doPost(CommonSysConst.getSysConfig().getChongQingCnpcUrl(), reqParam, new HashMap<>()); |
||||||
|
log.info("响应参数:" + response.toJSONString()); |
||||||
|
log.info("============end============"); |
||||||
|
|
||||||
|
JSONObject postMessage = response.getJSONObject("postMessage"); |
||||||
|
if (postMessage == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); |
||||||
|
} |
||||||
|
// 解密body
|
||||||
|
JSONObject body = decryptBody(response.getJSONObject("postMessage").getString("body")); |
||||||
|
if (!body.getInteger("status").equals(1)) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, body.getString("info")); |
||||||
|
} |
||||||
|
return body; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 解密body |
||||||
|
* @param bodyStr body加密字符串 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static JSONObject decryptBody(String bodyStr) { |
||||||
|
// 解密body
|
||||||
|
String decryptBody = AESTool.Decrypt(bodyStr, CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); |
||||||
|
return JSONObject.parseObject(decryptBody, JSONObject.class); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 解密电子券码 |
||||||
|
* @param couponCode 券码加密字符串 |
||||||
|
* @return 核销码 |
||||||
|
*/ |
||||||
|
public static String decryptCouponCode(String couponCode) { |
||||||
|
return AESTool.Decrypt(couponCode, CommonSysConst.getSysConfig().getChongQingCnpcCouponSignKey()); |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
//System.out.println(AESTool.Decrypt("A9D356D4614F874586EAF8678C8C3E7D8CD0EEF031ADA44DDAA3B342CE4BBE44F115AABE27324A6A1F049619139A1A889FCA0FB48EB6E1EA4B1B50F041961B2D686FE8B9696C02DF95BA99B342747D67ECC7847646C87993CF924F33C1308829","n2j30jxhl3rhuoci"));
|
||||||
|
System.out.println(AESTool.Decrypt("0E14C37B5657B48857A7D3AEFB8E24BACCA40AFF00B073FC22B4116FC97BAED3CBF38FDC5196FDF595637701FDEC1CDDA0AE518707D91B16DA65A63848AF6DB117D2F6E31A09074EB0E42422C6B3B15B96D230680D9E97E4324A384AA8E60F6E","5ojd0nkdqb1ff84t")); |
||||||
|
//System.out.println(AESTool.Decrypt("3549AD565800370205265D7518D26E5F40C90A61FDEB5DD73966126A5D25F5E9","5ojldakiz343a6yk"));
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,356 @@ |
|||||||
|
package com.hfkj.service.coupon.channel; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.common.Base64Util; |
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import com.hfkj.common.utils.MD5Util; |
||||||
|
import com.hfkj.common.utils.RedisUtil; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import com.hfkj.service.hlt.HuiLianTongUnionCardService; |
||||||
|
import org.apache.commons.collections4.MapUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.crypto.Cipher; |
||||||
|
import javax.crypto.spec.SecretKeySpec; |
||||||
|
import java.io.UnsupportedEncodingException; |
||||||
|
import java.net.URLEncoder; |
||||||
|
import java.security.MessageDigest; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 贵州中石化卡券业务 |
||||||
|
* @author hurui |
||||||
|
*/ |
||||||
|
@Component |
||||||
|
public class HuiLianTongCouponService { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(HuiLianTongCouponService.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private RedisUtil redisUtil; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取电子券类型列表 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject getHltFuelCoupList() throws Exception { |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("serviceType", "01"); |
||||||
|
map.put("distributorId", CommonSysConst.getSysConfig().getHuiliantongSinopecDistributorId() ); |
||||||
|
return HuiLianTongUnionCardService.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl() + "/getHltFuelCoupList", map); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 下单购买加油券 |
||||||
|
* @param orderNo |
||||||
|
* @param distCouCount |
||||||
|
* @param couTypeCode |
||||||
|
* @param phone |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject recharge(String orderNo, Integer distCouCount, String couTypeCode, String phone) throws Exception { |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("orderNo", orderNo); |
||||||
|
map.put("distCouCount", distCouCount); |
||||||
|
map.put("couTypeCode", couTypeCode); |
||||||
|
map.put("phone", phone); |
||||||
|
map.put("distributorId", CommonSysConst.getSysConfig().getHuiliantongSinopecDistributorId()); |
||||||
|
log.info("============请求任务Start============="); |
||||||
|
log.info("下单购买加油券-请求参数: " + JSON.toJSONString(map)); |
||||||
|
|
||||||
|
JSONObject returnObject = HuiLianTongUnionCardService.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl()+"/recharge", map); |
||||||
|
|
||||||
|
log.info("下单购买加油券-响应参数: " + returnObject.toJSONString()); |
||||||
|
log.info("============请求任务End=============="); |
||||||
|
return returnObject; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 购买加油券充值订单 |
||||||
|
* @param couNo 订单号 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject getPayOrderByCouNo(String couNo) throws Exception { |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("couNo", couNo); |
||||||
|
map.put("distributorId", CommonSysConst.getSysConfig().getHuiliantongSinopecDistributorId()); |
||||||
|
log.info("============请求任务Start============="); |
||||||
|
log.info("购买加油券充值订单-请求参数: " + JSON.toJSONString(map)); |
||||||
|
|
||||||
|
JSONObject returnObject = HuiLianTongUnionCardService.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl()+"/getPayOrderByCouNo", map); |
||||||
|
|
||||||
|
log.info("购买加油券充值订单-响应参数: " + returnObject.toJSONString()); |
||||||
|
log.info("============请求任务End=============="); |
||||||
|
return returnObject; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 购买加油券充值订单 |
||||||
|
* @param rechargeOrderId 订单号 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject costRechargeOrder(String rechargeOrderId) throws Exception { |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("rechargeOrderId", rechargeOrderId); |
||||||
|
map.put("distributorId", CommonSysConst.getSysConfig().getHuiliantongSinopecDistributorId()); |
||||||
|
|
||||||
|
|
||||||
|
log.info("============请求任务Start============="); |
||||||
|
log.info("购买加油券充值订单-请求参数: " + JSON.toJSONString(map)); |
||||||
|
|
||||||
|
JSONObject returnObject = HuiLianTongUnionCardService.request(CommonSysConst.getSysConfig().getHuiliantongSinopecUrl()+"/costRechargeOrder", map); |
||||||
|
|
||||||
|
log.info("购买加油券充值订单-响应参数: " + returnObject.toJSONString()); |
||||||
|
log.info("============请求任务End=============="); |
||||||
|
return returnObject; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取token |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public String getToken() throws Exception { |
||||||
|
Object token = redisUtil.get(CommonSysConst.getSysConfig().getHuiliantongAppNo()); |
||||||
|
if (token != null) { |
||||||
|
return token.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("appNo",CommonSysConst.getSysConfig().getHuiliantongAppNo()); |
||||||
|
map.put("appKey", MD5Util.encode(CommonSysConst.getSysConfig().getHuiliantongAppkey().getBytes())); |
||||||
|
|
||||||
|
// 获取token
|
||||||
|
JSONObject tokenObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getHuiliantongUrl()+"/api/api/auth/getAccessToken", JSON.toJSONString(map)); |
||||||
|
if (tokenObject.getString("result").equals("success")) { |
||||||
|
// 缓存到redis 有效期30分钟
|
||||||
|
redisUtil.set(CommonSysConst.getSysConfig().getHuiliantongAppNo(),tokenObject.getString("data"),60*30); |
||||||
|
return tokenObject.getString("data"); |
||||||
|
} |
||||||
|
|
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取电子券类型列表 |
||||||
|
* @param token |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject getCorpCouTypes(String token) { |
||||||
|
Map<String,Object> param = new HashMap<>(); |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("token", token); |
||||||
|
/* map.put("jsonData", get3DESEncryptECB(JSON.toJSONString(param), CommonSysConst.getSysConfig().getHuiliantongAppsecret())); |
||||||
|
StringJoiner urlParamStr = new StringJoiner("&"); |
||||||
|
urlParamStr.add(String.format("jsonData=%s", param)); |
||||||
|
urlParamStr.add(String.format("secretKey=%s",CommonSysConst.getSysConfig().getHuiliantongAppsecret())); |
||||||
|
map.put("sign", md5Capital(urlParamStr.toString()));*/ |
||||||
|
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getHuiliantongUrl()+"/coupon/api/coupon_corp/getCorpCouTypes", JSON.toJSONString(map)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取电子券类型列表 |
||||||
|
* @param token |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject getCouState(String token,String couNo) { |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("token", token); |
||||||
|
map.put("couNo", couNo); |
||||||
|
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getHuiliantongUrl()+"/coupon/api/coupon_corp/getCouState", JSON.toJSONString(map)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 商户派发电子券 |
||||||
|
* @param token |
||||||
|
* @param couTypeCode 电子卡券类型 |
||||||
|
* @param distCouCount 分配数量 |
||||||
|
* @param userPhone 用户手机号 |
||||||
|
* @param thirdUserId 用户编号 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject couJointDist(String token,String orderNo,String couTypeCode,Integer distCouCount,String userPhone,String thirdUserId) throws Exception { |
||||||
|
// 券列表
|
||||||
|
List<Map<String,Object>> objectList = new ArrayList<>(); |
||||||
|
Map<String,Object> object = new HashMap<>(); |
||||||
|
object.put("couTypeCode", couTypeCode); |
||||||
|
object.put("distCouCount", distCouCount); |
||||||
|
objectList.add(object); |
||||||
|
// 参数
|
||||||
|
Map<String,Object> param = new HashMap<>(); |
||||||
|
param.put("coupons", objectList); |
||||||
|
param.put("phone", userPhone); |
||||||
|
param.put("thirdUserId", thirdUserId); |
||||||
|
param.put("orderNo", orderNo); |
||||||
|
param.put("distOuCode", "guizhouhltcs"); |
||||||
|
|
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("token", token); |
||||||
|
map.put("jsonData", get3DESEncryptECB(JSON.toJSONString(param), CommonSysConst.getSysConfig().getHuiliantongAppkey())); |
||||||
|
StringJoiner joiner = new StringJoiner("&"); |
||||||
|
joiner.add("jsonData=" + JSON.toJSONString(param)); |
||||||
|
joiner.add("secretKey=" + CommonSysConst.getSysConfig().getHuiliantongAppsecret()); |
||||||
|
map.put("sign", md5Capital(joiner.toString())); |
||||||
|
|
||||||
|
String paramStr = "token="+MapUtils.getString(map, "token")+"&sign=" + MapUtils.getString(map, "sign")+"&jsonData=" + URLEncoder.encode(MapUtils.getString(map, "jsonData"),"UTF-8"); |
||||||
|
JSONObject object1 = HttpsUtils.doHuiLianTongPost(CommonSysConst.getSysConfig().getHuiliantongUrl() + "/coupon/api/coupon_corp/couJointDist?" + paramStr); |
||||||
|
return object1; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static String get3DESEncryptECB(String src,String secretKey) { |
||||||
|
try { |
||||||
|
Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding"); |
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(build3DesKey(secretKey), "DESede")); |
||||||
|
String base64Encode = getBase64Encode(cipher.doFinal(src.getBytes("UTF-8"))); |
||||||
|
return filter(base64Encode); |
||||||
|
} catch (Exception ex) { |
||||||
|
//加密失败,打日志
|
||||||
|
// //logger.error(ex,ex);
|
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public static String get3DESDecryptECB(String src,String secretKey){ |
||||||
|
try { |
||||||
|
Cipher cipher = Cipher.getInstance("DESede/ECB/PKCS5Padding"); |
||||||
|
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(build3DesKey(secretKey), "DESede")); |
||||||
|
byte[] base64DValue = getBase64Decode(src); |
||||||
|
byte ciphertext[] = cipher.doFinal(base64DValue); |
||||||
|
return new String(ciphertext, "UTF-8"); |
||||||
|
} catch (Exception e) { |
||||||
|
//解密失败,打日志
|
||||||
|
// //logger.error(e,e);
|
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* 根据字符串生成密钥字节数组 |
||||||
|
* @param keyStr 密钥字符串 |
||||||
|
* @return |
||||||
|
* @throws UnsupportedEncodingException |
||||||
|
*/ |
||||||
|
public static byte[] build3DesKey(String keyStr) throws UnsupportedEncodingException { |
||||||
|
byte[] key = new byte[24]; //声明一个24位的字节数组,默认里面都是0
|
||||||
|
byte[] temp = keyStr.getBytes("UTF-8"); //将字符串转成字节数组
|
||||||
|
|
||||||
|
/* |
||||||
|
* 执行数组拷贝 |
||||||
|
* System.arraycopy(源数组,从源数组哪里开始拷贝,目标数组,拷贝多少位) |
||||||
|
*/ |
||||||
|
if(key.length > temp.length){ |
||||||
|
//如果temp不够24位,则拷贝temp数组整个长度的内容到key数组中
|
||||||
|
System.arraycopy(temp, 0, key, 0, temp.length); |
||||||
|
}else{ |
||||||
|
//如果temp大于24位,则拷贝temp数组24个长度的内容到key数组中
|
||||||
|
System.arraycopy(temp, 0, key, 0, key.length); |
||||||
|
} |
||||||
|
return key; |
||||||
|
} |
||||||
|
/** |
||||||
|
* 对字符串进行Base64编码 |
||||||
|
* |
||||||
|
* |
||||||
|
* @return String 进行编码后的字符串 |
||||||
|
*/ |
||||||
|
|
||||||
|
public static String getBase64Encode(byte[] src) { |
||||||
|
String requestValue = ""; |
||||||
|
try { |
||||||
|
//BASE64Encoder base64en = new BASE64Encoder();
|
||||||
|
//requestValue = filter(base64en.encode(src));
|
||||||
|
|
||||||
|
requestValue = filter(Base64Util.encode(new String(src))); |
||||||
|
// //logger.debug(requestValue);
|
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
|
||||||
|
return requestValue; |
||||||
|
} |
||||||
|
|
||||||
|
public static byte[] getBase64Decode(String str) { |
||||||
|
byte[] src = null; |
||||||
|
|
||||||
|
try { |
||||||
|
//BASE64Decoder base64de = new BASE64Decoder();
|
||||||
|
//src = base64de.decodeBuffer(str);
|
||||||
|
src = filter(Base64Util.decode(new String(src))).getBytes(); |
||||||
|
} catch (Exception var3) { |
||||||
|
var3.printStackTrace(); |
||||||
|
} |
||||||
|
|
||||||
|
return src; |
||||||
|
} |
||||||
|
|
||||||
|
private static String filter(String str) { |
||||||
|
String output = null; |
||||||
|
StringBuffer sb = new StringBuffer(); |
||||||
|
for (int i = 0; i < str.length(); i++) { |
||||||
|
int asc = str.charAt(i); |
||||||
|
if (asc != 10 && asc != 13) |
||||||
|
sb.append(str.subSequence(i, i + 1)); |
||||||
|
} |
||||||
|
output = new String(sb); |
||||||
|
return output; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 大写 |
||||||
|
* @param s |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static String md5Capital(String s){ |
||||||
|
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; |
||||||
|
try { |
||||||
|
byte[] strTemp = s.getBytes(); |
||||||
|
//使用MD5创建MessageDigest对象
|
||||||
|
MessageDigest mdTemp = MessageDigest.getInstance("MD5"); |
||||||
|
mdTemp.update(strTemp); |
||||||
|
byte[] md = mdTemp.digest(); |
||||||
|
int j = md.length; |
||||||
|
char str[] = new char[j * 2]; |
||||||
|
int k = 0; |
||||||
|
for (int i = 0; i < j; i++) { |
||||||
|
byte b = md[i]; |
||||||
|
////logger.debug((int)b);
|
||||||
|
//将没个数(int)b进行双字节加密
|
||||||
|
str[k++] = hexDigits[b >> 4 & 0xf]; |
||||||
|
str[k++] = hexDigits[b & 0xf]; |
||||||
|
} |
||||||
|
return new String(str); |
||||||
|
} catch (Exception e) {return null;} |
||||||
|
} |
||||||
|
/* |
||||||
|
测试实例: |
||||||
|
String appkey = "q[*^%]#%675f"; |
||||||
|
String param = "{\"phone\":\"18550231381\"}"; |
||||||
|
String secretKey = "7EFD6D5D7052E29B4FBC4AD75CA737ED"; |
||||||
|
String jsonData = Coder.get3DESEncryptECB(param, appkey); |
||||||
|
System.out.println("jsonData:" + jsonData); |
||||||
|
|
||||||
|
StringJoiner joiner = new StringJoiner("&"); |
||||||
|
joiner.add("jsonData=" + param); |
||||||
|
joiner.add("secretKey=" + secretKey); |
||||||
|
String sign = Coder.md5Capital(joiner.toString()); |
||||||
|
System.out.println("sign:" + sign); |
||||||
|
|
||||||
|
jsonData:aOF3MZAENbJE/t+r4P0+RQGfhSEa5Hyq |
||||||
|
sign:835A267FCA8D36C6F79E308F18AECEE8*/ |
||||||
|
} |
@ -0,0 +1,142 @@ |
|||||||
|
package com.hfkj.service.coupon.channel; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import com.hfkj.common.utils.MD5Util; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* @serviceName .java |
||||||
|
* @author Sum1Dream |
||||||
|
* @version 1.0.0 |
||||||
|
* @Description // 中油优途中石油卡券
|
||||||
|
* @createTime 18:33 2023/11/13 |
||||||
|
**/ |
||||||
|
@Configuration |
||||||
|
public class PcytCNPCCouponService { |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCouponList |
||||||
|
* @Description // 获取卡券列表
|
||||||
|
* @Date 11:50 2024/4/7 |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCouponList() throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
paramMap.put("method" , "api.coupon.reserve"); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getPcytCnpcMerchant()); |
||||||
|
paramMap.put("sign", generateSign(paramMap , CommonSysConst.getSysConfig().getPcytCnpcSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getPcytCnpcPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCoupon |
||||||
|
* @Description // 获取电子券
|
||||||
|
* @Date 17:19 2024/4/7 |
||||||
|
|
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCoupon(String orderNo , String mobile, String reqCode) throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
|
||||||
|
paramMap.put("method" , "api.coupon.once"); |
||||||
|
paramMap.put("batchId" , orderNo); |
||||||
|
paramMap.put("mobile" , mobile); |
||||||
|
paramMap.put("reqCode" , reqCode); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getPcytCnpcMerchant()); |
||||||
|
paramMap.put("sign", generateSign(paramMap , CommonSysConst.getSysConfig().getPcytCnpcSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getPcytCnpcPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCouponQuery |
||||||
|
* @Description // 查询电子券信息
|
||||||
|
* @Date 17:25 2024/4/7 |
||||||
|
* @Param couponCode |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCouponQuery(String couponCode ) throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
|
||||||
|
paramMap.put("method" , "api.coupon.query"); |
||||||
|
paramMap.put("couponCode" , couponCode); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getPcytCnpcMerchant()); |
||||||
|
paramMap.put("sign", generateSign(paramMap , CommonSysConst.getSysConfig().getPcytCnpcSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getPcytCnpcPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author Sum1Dream |
||||||
|
* @Name getCouponDestroy |
||||||
|
* @Description // 作废电子券
|
||||||
|
* @Date 17:26 2024/4/7 |
||||||
|
* @Param couponCode |
||||||
|
* @return com.alibaba.fastjson.JSONObject |
||||||
|
*/ |
||||||
|
public static JSONObject getCouponDestroy(String couponCode ) throws Exception { |
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
|
||||||
|
paramMap.put("method" , "api.coupon.destroy"); |
||||||
|
paramMap.put("couponCode" , couponCode); |
||||||
|
paramMap.put("merchant" ,CommonSysConst.getSysConfig().getPcytCnpcMerchant()); |
||||||
|
paramMap.put("sign", generateSign(paramMap , CommonSysConst.getSysConfig().getPcytCnpcSecret())); |
||||||
|
return HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getPcytCnpcPostUrl() , paramSort(paramMap), new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 排序 |
||||||
|
* @param param |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
private static String paramSort(final Map<String, Object> param) { |
||||||
|
Set<String> keySet = param.keySet(); |
||||||
|
String[] keyArray = keySet.toArray(new String[keySet.size()]); |
||||||
|
StringBuilder sb = new StringBuilder(); |
||||||
|
for (String k : keyArray) { |
||||||
|
if (StringUtils.isBlank(sb.toString())) { |
||||||
|
sb.append(k).append("=").append(param.get(k)); |
||||||
|
} else { |
||||||
|
sb.append("&").append(k).append("=").append(param.get(k)); |
||||||
|
} |
||||||
|
} |
||||||
|
return sb.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 签名 |
||||||
|
* @param map |
||||||
|
* @param key |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static String generateSign(Map<String , Object> map , String key) throws Exception { |
||||||
|
Set<String> keySet = map.keySet(); |
||||||
|
String[] keyArray = keySet.toArray(new String[keySet.size()]); |
||||||
|
Arrays.sort(keyArray); |
||||||
|
StringBuilder sb = new StringBuilder(); |
||||||
|
for (String k : keyArray) { |
||||||
|
if (k.equals("sign") || k.equals("secret")) { |
||||||
|
continue; |
||||||
|
} |
||||||
|
if (map.get(k) != null) // 参数值为空,则不参与签名
|
||||||
|
{ |
||||||
|
sb.append(k).append("=").append(map.get(k)).append("&"); |
||||||
|
} |
||||||
|
} |
||||||
|
sb.append("secret=").append(key); |
||||||
|
return MD5Util.encode(sb.toString().getBytes()).toUpperCase(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
package com.hfkj.service.coupon.impl; |
||||||
|
|
||||||
|
import com.hfkj.dao.BsOrderCouponNoMapper; |
||||||
|
import com.hfkj.entity.BsOrderCouponNo; |
||||||
|
import com.hfkj.entity.BsOrderCouponNoExample; |
||||||
|
import com.hfkj.service.coupon.BsOrderCouponNoService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: BsOrderCouponNoServiceImpl |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/5/11 |
||||||
|
**/ |
||||||
|
@Service("orderCouponNoService") |
||||||
|
public class BsOrderCouponNoServiceImpl implements BsOrderCouponNoService { |
||||||
|
@Resource |
||||||
|
private BsOrderCouponNoMapper orderCouponNoMapper; |
||||||
|
@Override |
||||||
|
public void editData(BsOrderCouponNo data) { |
||||||
|
data.setUpdateTime(new Date()); |
||||||
|
if (data.getId() == null) { |
||||||
|
data.setCreateTime(new Date()); |
||||||
|
orderCouponNoMapper.insert(data); |
||||||
|
} else { |
||||||
|
orderCouponNoMapper.updateByPrimaryKey(data); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<BsOrderCouponNo> getListByCouponOrderId(Long couponOrderId) { |
||||||
|
BsOrderCouponNoExample example = new BsOrderCouponNoExample(); |
||||||
|
example.createCriteria().andCouponOrderIdEqualTo(couponOrderId); |
||||||
|
return orderCouponNoMapper.selectByExample(example); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.hfkj.service.coupon.impl; |
||||||
|
|
||||||
|
import com.hfkj.dao.BsOrderCouponMapper; |
||||||
|
import com.hfkj.entity.BsOrderCoupon; |
||||||
|
import com.hfkj.entity.BsOrderCouponExample; |
||||||
|
import com.hfkj.service.coupon.BsOrderCouponService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: BsOrderCouponServiceImpl |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/5/10 |
||||||
|
**/ |
||||||
|
@Service("orderCouponService") |
||||||
|
public class BsOrderCouponServiceImpl implements BsOrderCouponService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsOrderCouponMapper orderCouponMapper; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void editData(BsOrderCoupon data) { |
||||||
|
data.setUpdateTime(new Date()); |
||||||
|
if (data.getId() == null) { |
||||||
|
data.setCreateTime(new Date()); |
||||||
|
orderCouponMapper.insert(data); |
||||||
|
} else { |
||||||
|
orderCouponMapper.updateByPrimaryKey(data); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<BsOrderCoupon> getListByChildOrderNo(String orderChildOrderNo) { |
||||||
|
BsOrderCouponExample example = new BsOrderCouponExample(); |
||||||
|
example.createCriteria().andChildOrderNoEqualTo(orderChildOrderNo); |
||||||
|
return orderCouponMapper.selectByExample(example); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,256 @@ |
|||||||
|
package com.hfkj.service.hlt; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
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.pay.util.MD5Util; |
||||||
|
import com.hfkj.common.utils.DateUtil; |
||||||
|
import com.hfkj.common.utils.DesUtil; |
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import org.apache.commons.collections4.MapUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.nio.charset.Charset; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.LinkedHashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* 汇联通会员卡业务接口【贵州高速工会卡】 |
||||||
|
* @author hurui |
||||||
|
*/ |
||||||
|
public class HuiLianTongUnionCardService { |
||||||
|
private static Logger log = LoggerFactory.getLogger(HuiLianTongUnionCardService.class); |
||||||
|
private static final String HLT_CARD_REQUEST_URL= "http://hltgz.com:4010/api/v2/execute.json"; |
||||||
|
private static final String HLT_CARD_ACCESS_CODE= "6FCAE1470CEF465988351BB65ABAA8AE"; |
||||||
|
private static final String HLT_CARD_SIGN_CODE = "F8E91A3C"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据手机号查询工会卡 |
||||||
|
* @param phone |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject queryCardByMobile(String phone) throws Exception { |
||||||
|
Map<String,Object> dataMap = new HashMap<>(); |
||||||
|
dataMap.put("userMobile", phone); |
||||||
|
return request("qgk/queryCardByMobile", dataMap); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询卡信息 |
||||||
|
* @param cardNo 工会卡号 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject queryCardInfo(String cardNo) throws Exception { |
||||||
|
Map<String,Object> dataMap = new HashMap<>(); |
||||||
|
dataMap.put("cardNo", cardNo); |
||||||
|
return request("qgk/queryCardInfo", dataMap); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查询余额 |
||||||
|
* @param cardNo 工会卡号 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject queryBalance(String cardNo) throws Exception { |
||||||
|
Map<String,Object> dataMap = new HashMap<>(); |
||||||
|
dataMap.put("cardType", "ghk"); |
||||||
|
dataMap.put("cardNo", cardNo); |
||||||
|
return request("qtk/queryBalance", dataMap); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据业务类型查询消费记录 |
||||||
|
* @param businessType 业务类型 1.卖中石化加油券的,固定填sinopec_oil_code 2.其他商品或服务的,固定填hisen_consume |
||||||
|
* @param cardNo 工会卡号 |
||||||
|
* @param page 页数 |
||||||
|
* @param pageSize 每页条数 |
||||||
|
* @param sdate 起始日期 yyyy-MM-dd格式 |
||||||
|
* @param edate 截止日期 yyyy-MM-dd格式 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject queryConsumptionRecordByBusiness(String businessType,String cardNo,Long sdate,Long edate,Integer page,Integer pageSize) throws Exception { |
||||||
|
try { |
||||||
|
Map<String,Object> dataMap = new HashMap<>(); |
||||||
|
dataMap.put("businessType", businessType); |
||||||
|
dataMap.put("cardNo", cardNo); |
||||||
|
dataMap.put("page", page); |
||||||
|
dataMap.put("pageSize", pageSize); |
||||||
|
if (sdate != null) { |
||||||
|
dataMap.put("sdate", DateUtil.date2String(new Date(sdate), "yyyy-MM-dd")); |
||||||
|
} |
||||||
|
if (edate != null) { |
||||||
|
dataMap.put("edate", DateUtil.date2String(new Date(edate), "yyyy-MM-dd")); |
||||||
|
} |
||||||
|
return request("qtk/queryConsumptionRecordByBusiness", dataMap); |
||||||
|
} catch (Exception e) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_TIMED_OUT, ""); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 充值 |
||||||
|
* @param orderNo 订单号 |
||||||
|
* @param cardNo 卡号 |
||||||
|
* @param tranAmount 支付金额 |
||||||
|
* @param businessType 业务类型 1.卖中石化加油券的,固定填sinopec_oil_code 2.其他商品或服务的,固定填hisen_consume |
||||||
|
* @param tranVoucher 银行卡充值可填银行卡号;支付宝、微信充值可填相应的扣款单号;接入方也可自定义填入交易流水跟踪号,但长度不能超过50 |
||||||
|
* @param tranDesc 交易描述 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject deposit(String orderNo, String cardNo, BigDecimal tranAmount, String businessType, String tranVoucher , String tranDesc) throws Exception { |
||||||
|
Map<String,Object> dataMap = new HashMap<>(); |
||||||
|
dataMap.put("orderNo", orderNo); |
||||||
|
dataMap.put("cardType", "ghk"); |
||||||
|
dataMap.put("cardNo", cardNo); |
||||||
|
dataMap.put("tranAmount", tranAmount); |
||||||
|
dataMap.put("tranChannel", "HiSen"); |
||||||
|
dataMap.put("businessType", businessType); |
||||||
|
dataMap.put("tranVoucher", tranVoucher); |
||||||
|
dataMap.put("tranDesc", tranDesc); |
||||||
|
|
||||||
|
|
||||||
|
log.info("============请求任务Start============="); |
||||||
|
log.info("汇联通充值-请求参数: " + JSON.toJSONString(dataMap)); |
||||||
|
|
||||||
|
JSONObject returnObject = request("qtk/deposit", dataMap); |
||||||
|
|
||||||
|
log.info("汇联通充值-响应参数: " + returnObject.toJSONString()); |
||||||
|
log.info("============请求任务End=============="); |
||||||
|
return returnObject; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 支付 |
||||||
|
* @param orderNo 订单号 |
||||||
|
* @param cardNo 卡号 |
||||||
|
* @param tranAmount 支付金额 |
||||||
|
* @param businessType 业务类型 1.卖中石化加油券的,固定填sinopec_oil_code 2.其他商品或服务的,固定填hisen_consume |
||||||
|
* @param instCode 消费终端号 |
||||||
|
* @param goodsDesc 商品描述 |
||||||
|
* @param tranDesc 交易描述 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject consumption(String orderNo, String cardNo, BigDecimal tranAmount, String businessType, String instCode,String goodsDesc, String tranDesc) throws Exception { |
||||||
|
Map<String,Object> dataMap = new HashMap<>(); |
||||||
|
dataMap.put("orderNo", orderNo); |
||||||
|
dataMap.put("cardType", "ghk"); |
||||||
|
dataMap.put("cardNo", cardNo); |
||||||
|
dataMap.put("checkPassword", "N"); |
||||||
|
dataMap.put("tranAmount", tranAmount); |
||||||
|
dataMap.put("tranChannel", "HiSen"); |
||||||
|
dataMap.put("businessType", businessType); |
||||||
|
dataMap.put("instCode", instCode); |
||||||
|
dataMap.put("goodsDesc", goodsDesc); |
||||||
|
dataMap.put("tranDesc", tranDesc); |
||||||
|
return request("qtk/consumption", dataMap); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 业务请求 |
||||||
|
* @param method 接口名称 |
||||||
|
* @param param 业务参数 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject request(String method,Map<String,Object> param) throws Exception { |
||||||
|
// 签名码
|
||||||
|
String signCode = HLT_CARD_SIGN_CODE; |
||||||
|
|
||||||
|
Map<String,Object> map = new LinkedHashMap<>(); |
||||||
|
map.put("accessCode", HLT_CARD_ACCESS_CODE); |
||||||
|
map.put("requestId", System.currentTimeMillis()); |
||||||
|
map.put("method", method); |
||||||
|
|
||||||
|
// DES加密
|
||||||
|
map.put("data", DesUtil.encode(JSONObject.toJSONString(param), Charset.forName("UTF-8"),signCode).replace("\\n", "")); |
||||||
|
|
||||||
|
// 数据签名字符串
|
||||||
|
String str = (MapUtils.getString(map,"accessCode")+signCode); |
||||||
|
str +=(MapUtils.getString(map,"requestId")+signCode) ; |
||||||
|
str += (MapUtils.getString(map,"method") + signCode); |
||||||
|
str += (MapUtils.getString(map,"data") + signCode); |
||||||
|
|
||||||
|
// MD5加密
|
||||||
|
map.put("sign", MD5Util.MD5Encode(str, "UTF-8").toUpperCase()); |
||||||
|
|
||||||
|
log.info("============请求任务Start============="); |
||||||
|
log.info("请求参数: " + JSON.toJSONString(map)); |
||||||
|
|
||||||
|
JSONObject returnObject = HttpsUtils.doPost(HLT_CARD_REQUEST_URL, JSON.toJSONString(map)); |
||||||
|
|
||||||
|
log.info("响应参数: " + returnObject.toJSONString()); |
||||||
|
log.info("============请求任务End=============="); |
||||||
|
return returnObject; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 退款 |
||||||
|
* @param refundOrderNo 退款订单号 |
||||||
|
* @param origOrderNo 支付订单号 |
||||||
|
* @return |
||||||
|
* @throws Exception |
||||||
|
*/ |
||||||
|
public static JSONObject refund(String refundOrderNo, String origOrderNo) throws Exception { |
||||||
|
Map<String,Object> dataMap = new HashMap<>(); |
||||||
|
dataMap.put("orderNo", refundOrderNo); |
||||||
|
dataMap.put("origOrderNo", origOrderNo); |
||||||
|
dataMap.put("checkPassword", "N"); |
||||||
|
|
||||||
|
|
||||||
|
log.info("============请求任务Start============="); |
||||||
|
log.info("汇联通退款-请求参数: " + JSON.toJSONString(dataMap)); |
||||||
|
|
||||||
|
JSONObject returnObject = request("qtk/refund", dataMap); |
||||||
|
|
||||||
|
log.info("汇联通退款-响应参数: " + returnObject.toJSONString()); |
||||||
|
log.info("============请求任务End=============="); |
||||||
|
return returnObject; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 解析响应的参数 |
||||||
|
* @param param 参数 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public static JSONObject resolveResponse(String param) { |
||||||
|
String data = param.replace("\\n", ""); |
||||||
|
String decodeData = DesUtil.decode(HLT_CARD_SIGN_CODE, data, Charset.forName("UTF-8")); |
||||||
|
|
||||||
|
log.info("============请求任务Start============="); |
||||||
|
log.info("解析响应的参数-请求参数: " + data); |
||||||
|
|
||||||
|
JSONObject returnObject = JSONObject.parseObject(decodeData); |
||||||
|
|
||||||
|
log.info("解析响应的参数-响应参数: " + returnObject.toJSONString()); |
||||||
|
log.info("============请求任务End=============="); |
||||||
|
|
||||||
|
return returnObject; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
// {"respMessage":"ok","data":"Gbkl57c3fEBg+E3HfPuQ580JLkHaQPyf1P7My1oYOyJSIG4i8jYxovGVk4V8Rk58mjDswB8Vpy4E\nyj/wi/UNr8TDne094+yu","sign":"47186141FD8B3FB6CCB590F58321D9C6","respCode":"0000","responseId":"1669202185936"}
|
||||||
|
String data = "Gbkl57c3fEBg+E3HfPuQ55SDLVyAf2Ys3VN1cifAfXIoT1gnbFR0NaiH/z1OIZZiuqlFwDLLu6n4\n" + |
||||||
|
"VBkM8fF5jVEekFNLY57NgRfRr4BghKXdIr8hdPJnbfOO0VtjITPrrZWwMDwfYzJulYhBsNGCubov\n" + |
||||||
|
"9ruAA0DN0ESoH765nvlH0lI/wdIOvRE7GyTfQzzT68i5p+Qf/k7yjQk22l4KUfuUVM+jMeW95xkd\n" + |
||||||
|
"+gVJvWctjBC0DN3zi3CwsVgQwVmj".replace("\\n", ""); |
||||||
|
String decodeData = DesUtil.decode(HLT_CARD_SIGN_CODE, data, Charset.forName("UTF-8")); |
||||||
|
System.out.println(JSONObject.parseObject(decodeData)); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.hfkj.sysenum; |
||||||
|
|
||||||
|
/** |
||||||
|
* 产品来源 |
||||||
|
* @className: SecMenuTypeEnum |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/4/10 |
||||||
|
**/ |
||||||
|
public enum GoodsVpdSourceEnum { |
||||||
|
|
||||||
|
/** |
||||||
|
* 内部虚拟商品 |
||||||
|
*/ |
||||||
|
type1(1, "内部虚拟商品"), |
||||||
|
/** |
||||||
|
* 贵州中石化 |
||||||
|
*/ |
||||||
|
type4(4, "贵州中石化"), |
||||||
|
/** |
||||||
|
* 重庆中石油 |
||||||
|
*/ |
||||||
|
type5(5, "重庆中石油"), |
||||||
|
/** |
||||||
|
* 比邻星停车券 |
||||||
|
*/ |
||||||
|
type6(6, "比邻星停车券"), |
||||||
|
/** |
||||||
|
* 四川中石油 |
||||||
|
*/ |
||||||
|
type7(7, "四川中石油"), |
||||||
|
/** |
||||||
|
* 中油优途中石油 |
||||||
|
*/ |
||||||
|
type10(10, "中油优途中石油"), |
||||||
|
; |
||||||
|
|
||||||
|
private int code; |
||||||
|
|
||||||
|
private String name; |
||||||
|
|
||||||
|
|
||||||
|
GoodsVpdSourceEnum(int code, String name) { |
||||||
|
this.code = code; |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
public int getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCode(int code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.hfkj.sysenum.order; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
|
||||||
|
/** |
||||||
|
* 卡券编号订单状态 |
||||||
|
* @className: OrderCouponNoStatusEnum |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/5/11 |
||||||
|
**/ |
||||||
|
@Getter |
||||||
|
public enum OrderCouponNoStatusEnum { |
||||||
|
/** |
||||||
|
* 待支付 |
||||||
|
*/ |
||||||
|
status1(1, "未派发"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 已支付 |
||||||
|
*/ |
||||||
|
status2(2, "已派发"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 已完成 |
||||||
|
*/ |
||||||
|
status3(3, "已使用"), |
||||||
|
|
||||||
|
/** |
||||||
|
* 已退款 |
||||||
|
*/ |
||||||
|
status4(4, "已过期"), |
||||||
|
; |
||||||
|
|
||||||
|
private final int code; |
||||||
|
|
||||||
|
private final String name; |
||||||
|
|
||||||
|
|
||||||
|
OrderCouponNoStatusEnum(int code, String name) { |
||||||
|
this.code = code; |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
wechatMaAppid= |
||||||
|
wechatMaSecret= |
||||||
|
wechatMpAppid= |
||||||
|
wechatMpSecret= |
||||||
|
|
||||||
|
huiPayPreorderNotifyUrl=https://phgcs.dctpay.com/order/notify/huipay |
||||||
|
|
||||||
|
# ChongQingCNPC configuration parameters |
||||||
|
chongQingCnpcUrl=http://cqpingan.wisdomyt.cn/d/cross/api |
||||||
|
chongQingCnpcMerNo=7ygt1b2b8rpl7vttm6 |
||||||
|
chongQingCnpcMerKey=5ojd0nkdqb1ff84t |
||||||
|
chongQingCnpcCouponSignKey=pzj69n2r8l1l3kry |
||||||
|
|
||||||
|
# PetroChinaYouTu configuration parameters |
||||||
|
pcytCnpcPostUrl=https://api.coupon.shuangpenghui.com//business/entry |
||||||
|
pcytCnpcMerchant=618809656349 |
||||||
|
pcytCnpcSecret=xstEWAhjw74GzMkXcPr2Cf7z00aYXaSy |
||||||
|
|
||||||
|
# BiLingXing |
||||||
|
blxPostUrl=https://zhctapplet.gyzhtc.com/gateway |
||||||
|
|
||||||
|
huiliantongUrl=https://gzapi.deepermobile.com.cn |
||||||
|
huiliantongAppNo=guizhouhuilt |
||||||
|
huiliantongAppkey=e0ja2Ex%2BmQ2hIPF6x%2BHA%3D |
||||||
|
huiliantongAppsecret=52662415DDCE55C7BA34223BCF53877A |
||||||
|
huiliantongSinopecDistributorId=aNId4A3X |
||||||
|
huiliantongDistributorId=1JnL8YMV |
||||||
|
huiliantongSinopecUrl=fuelCoupons |
@ -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;
@Resource
private BsUserService userService;
@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_ID5);
// 验证码缓存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.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;
@Resource
private BsUserService userService;
@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_ID5);
// 验证码缓存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…
Reference in new issue