main^2^2
黄海 11 months ago
parent a440bc3941
commit eb9edc8e57

@ -17,9 +17,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import static com.charge.util.ToolDateTime.dateFormat;
@RestController
@RequestMapping("/ZhuQue")
public class YltControllerForWx {
@ -38,6 +42,11 @@ public class YltControllerForWx {
YltModel ym = new YltModel();
//模拟一下假的订单【中东港】 select * from t_equipment_charge_order where station_id=114
String tmp_order_no = "2022012911045715187";
//模拟一下假的订单【西点药业湛江路】 select * from t_equipment_charge_order where station_id=85
//String tmp_order_no="2020092312312312312";
/**
*
*
@ -45,10 +54,12 @@ public class YltControllerForWx {
*/
@PostMapping("/station/isThirdPartyStation")
public ResultVO isThirdPartyStation(String order_no) {
Record record = ym.getThirdPartyStation(order_no);
Record record = ym.getThirdPartyStation(tmp_order_no);
if (record == null) {
ym.writeCallLog(order_no, "检查到不是需要免费的道闸所在车场,无需发送减免消息!!", "-1");
return ResultVO.custom("不在合作的道闸车场内", -1);
}
ym.writeCallLog(order_no, "检查到是需要免费的道闸所在车场,发送减免消息!!", "0");
return ResultVO.success("在合作的道闸车场内");
}
@ -68,11 +79,8 @@ public class YltControllerForWx {
*/
@PostMapping("/station/SyncChargePilePay")
public ResultVO SyncChargePilePay(String order_no, String charge_plate_no) {
//模拟一下假的订单
order_no="2023010415453464446";
//根据订单号获取到第三方方面提供的车场信息
Record thirdPartyStation = ym.getThirdPartyStation(order_no);
Record thirdPartyStation = ym.getThirdPartyStation(tmp_order_no);
if (thirdPartyStation == null) {
return ResultVO.custom("检查到不是需要免费的道闸所在车场,无需发送减免消息!!", -1);
}
@ -97,15 +105,13 @@ public class YltControllerForWx {
//log.info("发现闸机提供商:" + name + ",parkId=" + parkId);
//订单信息
Record ddRecord = ym.getOrderByNo(order_no);
Record ddRecord = ym.getOrderByNo(tmp_order_no);
int stationId = ddRecord.getInt("station_id");//电站ID
//获取车场名称
String stationName = ym.getStationById(stationId).getStr("station_name");
//设备号
int deviceId = ddRecord.getInt("equipment_id");//充电桩ID
//充电桩名称
String deviceName = ym.getEquipmentById(deviceId).getStr("equipment_name");
//车位号
String spaceNo = ddRecord.getInt("connector_id").toString();
//充电量
@ -135,8 +141,8 @@ public class YltControllerForWx {
jo.put("reqId", UUID.randomUUID().toString().toUpperCase());//每次请求的唯一标识如果是异步接口异步响应消息的reqId会与原请求的reqId一致。每次请求必须唯一
jo.put("orderNo", order_no);//订单号
jo.put("plateNo", charge_plate_no);//车牌号
jo.put("startTime", charge_begin_time.replace(".0",""));//开始时间
jo.put("endTime", charge_end_time.replace(".0",""));//结束时间
jo.put("startTime", charge_begin_time.replace(".0", ""));//开始时间
jo.put("endTime", charge_end_time.replace(".0", ""));//结束时间
jo.put("stationId", stationId);//电站ID
jo.put("stationName", stationName);//电站名称
jo.put("deviceId", deviceId);//充电桩ID
@ -206,5 +212,38 @@ public class YltControllerForWx {
return null;
}
/**
*
*
* @param order_no
*/
@PostMapping("/station/needShowYhj")
public ResultVO needShowYhj(String order_no) {
//1、如果没有获取过但不是今天的不能获取,当前日期年月日拼接成一个8位长度的字符串
// 获取当前日期
Date currentDate = new Date();
// 创建SimpleDateFormat对象设置日期格式为"yyyyMMdd"
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
// 格式化日期
String formattedDate = dateFormat.format(currentDate);
// 输出格式化后的日期字符串
if (!order_no.substring(0, 8).equals(formattedDate)) {
return ResultVO.custom("不是今天的订单,无法派发优惠券", -1);
}
//2、不是指定场站的订单不能获取
Record record = ym.getThirdPartyStation(tmp_order_no);
if (record == null) {
return ResultVO.custom("不在合作的道闸车场内", -1);
}
//3、如果获取过了不能再次获取
Record r = ym.getDZlog(order_no);
if (r != null) {
return ResultVO.custom("已经发放过优惠券,不能再次发放!", -1);
}
//4、可以获取
return ResultVO.success();
}
}

@ -28,13 +28,7 @@ public class YltModel {
* @return
*/
public Record getThirdPartyStation(String order_no) {
//因为测试库与生产库是两个库,在生产库中产生的订单号,在测试库中是无法获取到的,所以先写死,再考虑与吴缤研究是否可以将
//中东港114
//驿来特充电站西点药业湛江路85
String sql = "select * from t_ext_dz_station where station_id=114";
Record record = Db.findFirst(sql);
//Record record = getOrderByNo(order_no);
Record record = getOrderByNo(order_no);
if (record == null) {
return null;
}
@ -119,4 +113,29 @@ public class YltModel {
Db.save("t_ext_dz_log", "order_no", record);
}
/**
*
*
* @param order_no
* @return
*/
public Record getDZlog(String order_no) {
String sql = "select * from t_ext_dz_log where order_no=?";
return Db.findFirst(sql, order_no);
}
/**
*
*
* @param order_no
* @param message
* @param errorCode
*/
public void writeCallLog(String order_no, String message, String errorCode) {
Record record = new Record();
record.set("order_no", order_no);
record.set("message", message);
record.set("errorCode", errorCode);
Db.save("t_ext_dz_call_log", "id", record);
}
}

@ -3,7 +3,7 @@ spring:
mongodb:
uri: mongodb://yltcharge:yltcharge@dds-bp176c45f561f0041.mongodb.rds.aliyuncs.com:3717,dds-bp176c45f561f0042.mongodb.rds.aliyuncs.com:3717/yltcharge?replicaSet=mgset-36440453
datasource:
url: jdbc:mysql://rm-bp1ux6tuk49er80t9.mysql.rds.aliyuncs.com:3306/yltcharge?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://rm-bp1ux6tuk49er80t9.mysql.rds.aliyuncs.com:3306/yltcharge?useUnicode=true&characterEncoding=UTF-8
username: ylt
password: Ycharge666
driver-class-name: com.mysql.jdbc.Driver

@ -3,7 +3,7 @@ spring:
mongodb:
uri: mongodb://ycharge:ycharge@dds-2vc0a87af9cfc5841.mongodb.cn-chengdu.rds.aliyuncs.com:3717,dds-2vc0a87af9cfc5842.mongodb.cn-chengdu.rds.aliyuncs.com:3717/ycharge
datasource:
url: jdbc:mysql://rm-2vchv2m4c8dn72884.mysql.cn-chengdu.rds.aliyuncs.com:3306/ycharge?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://rm-2vchv2m4c8dn72884.mysql.cn-chengdu.rds.aliyuncs.com:3306/ycharge?useUnicode=true&characterEncoding=UTF-8
username: ycharge
password: Ycharge666
driver-class-name: com.mysql.jdbc.Driver
@ -74,8 +74,8 @@ aliyunvinapi:
wx:
config:
appId: wxf077d1a84a951991
appScrect: f159a92730247f7e574bd8c538ae6910
appId: wx9863e002c6a5f8bd
appScrect: ee9f5f214f2054f504544476ae542231
aliSms:
product: Dysmsapi

Loading…
Cancel
Save