Commit 21b4e363 authored by fanjr's avatar fanjr

pda接口修改

parent 972331cd
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.cftech.couponrecord.dao.CouponrecordMapper;
import com.cftech.couponrecord.model.Couponrecord;
import com.cftech.couponrecord.service.PdaCouponrecordService;
import com.cftech.couponrecord.util.Md5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
......@@ -28,6 +29,17 @@ public class PdaCouponrecordServiceImpl implements PdaCouponrecordService {
couponrecordMapper.insertPdaLog(map);
String facilityNo = obj.get("facilityNo")+"";
String number = obj.get("number")+"";
String token = obj.get("token")+"";
if(!token.equals("268710d79f63bcdebdf3f745f84d146f")){
rtnJson.put("code", 500);
rtnJson.put("msg", "接口调用失败!");
map = new HashMap<String,Object>();
map.put("id",logId);
map.put("resultJson",rtnJson.toString());
map.put("status",1);
couponrecordMapper.updatePdaLog(map);
return rtnJson;
}
try {
//是否已核销
Couponrecord info = couponrecordMapper.isWriteOff(number);
......
package com.cftech.couponrecord.util;
import java.security.MessageDigest;
/**
* Created by 16444 on 2020/11/30.
*/
public class Md5Utils {
private final static String[] hexDigits = {"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "a", "b", "c", "d", "e", "f"};
/**
* 转换字节数组为16进制字串
* @param b 字节数组
* @return 16进制字串
*/
public static String byteArrayToHexString(byte[] b) {
StringBuilder resultSb = new StringBuilder();
for (byte aB : b) {
resultSb.append(byteToHexString(aB));
}
return resultSb.toString();
}
/**
* 转换byte到16进制
* @param b 要转换的byte
* @return 16进制格式
*/
private static String byteToHexString(byte b) {
int n = b;
if (n < 0) {
n = 256 + n;
}
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
/**
* MD5编码
* @param origin 原始字符串
* @return 经过MD5加密之后的结果
*/
public static String MD5Encode(String origin) {
String resultString = null;
try {
resultString = origin;
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(resultString.getBytes("UTF-8"));
resultString = byteArrayToHexString(md.digest());
} catch (Exception e) {
e.printStackTrace();
}
return resultString;
}
}
......@@ -20,7 +20,7 @@ import java.util.Map;
* Fanjr
*/
@RestController
@RequestMapping("/pda/writeOff/coupon")
@RequestMapping("/mobile/pda/coupon")
public class PdaCouponrecordController {
@Autowired
......
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