修改金额

This commit is contained in:
yuyang 2021-08-17 17:33:57 +08:00
parent a8f0416be7
commit 609d0c3bf3
9 changed files with 136 additions and 57 deletions

View File

@ -51,7 +51,7 @@ public class XhpcChargingStationApiController extends BaseController {
* @return * @return
*/ */
@GetMapping(value = "/getWXXhpcChargingStationMessage") @GetMapping(value = "/getWXXhpcChargingStationMessage")
public AjaxResult getWXXhpcChargingStationMessage(@RequestParam(value = "chargingStationId", required = true) Long chargingStationId, @RequestParam(value = "longitude", required = true) String longitude, @RequestParam(value = "latitude", required = true) String latitude) { public AjaxResult getWXXhpcChargingStationMessage(@RequestParam(value = "chargingStationId") Long chargingStationId, @RequestParam(value = "longitude") String longitude, @RequestParam(value = "latitude") String latitude) {
return AjaxResult.success(xhpcChargingStationService.getWXXhpcChargingStationMessage(chargingStationId, longitude, latitude)); return AjaxResult.success(xhpcChargingStationService.getWXXhpcChargingStationMessage(chargingStationId, longitude, latitude));
} }

View File

@ -655,6 +655,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
map.put("status", 3); map.put("status", 3);
if(cacheMap.get("status")!=null){ if(cacheMap.get("status")!=null){
map.put("soc", cacheMap.get("status").toString()+"%"); map.put("soc", cacheMap.get("status").toString()+"%");
}else{
map.put("soc", "0%");
} }
if(cacheMap.get("remainingTime")!=null){ if(cacheMap.get("remainingTime")!=null){
int number = (int)cacheMap.get("remainingTime"); int number = (int)cacheMap.get("remainingTime");

View File

@ -313,7 +313,7 @@
and del_flag = 0 and del_flag = 0
and status = 0 limit 1) as type, and status = 0 limit 1) as type,
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag =0 and charging_station_id=charging_station_id) as common, (select count(terminal_id) from xhpc_terminal where status=0 and del_flag =0 and charging_station_id=charging_station_id) as common,
(select GROUP_CONCAT(serial_number) from xhpc_terminal where status=0 and del_flag =0 and charging_station_id=cs.charging_station_id) as serialNumbers, (select GROUP_CONCAT(serial_number) from xhpc_terminal where status=0 and del_flag =0 and charging_station_id=charging_station_id) as serialNumbers,
(select GROUP_CONCAT(dict_value) from xhpc_dict_biz where FIND_IN_SET(dict_key,service_facilities ) and code= 'service_facilities' and parent_id > 0 and del_flag = 0) as serviceFacilitiesName, (select GROUP_CONCAT(dict_value) from xhpc_dict_biz where FIND_IN_SET(dict_key,service_facilities ) and code= 'service_facilities' and parent_id > 0 and del_flag = 0) as serviceFacilitiesName,
name as name, name as name,
reminder_instructions as reminderInstructions, reminder_instructions as reminderInstructions,

View File

@ -23,7 +23,7 @@ public interface PileOrderService {
* @return * @return
*/ */
@GetMapping("/chargeOrder/pileStartup") @GetMapping("/chargeOrder/pileStartup")
R pileStartup(@RequestParam("orderNo") String orderNo, @RequestParam("status") Integer status, @RequestParam("remark") String remark); R pileStartup(@RequestParam(value = "orderNo") String orderNo, @RequestParam(value = "status") Integer status, @RequestParam(value = "remark") String remark);
/** /**
* 桩停止回调接口 * 桩停止回调接口
@ -34,6 +34,6 @@ public interface PileOrderService {
* @return * @return
*/ */
@GetMapping("/chargeOrder/pileStop") @GetMapping("/chargeOrder/pileStop")
R pileStop(@RequestParam("orderNo") String orderNo, @RequestParam("status") Integer status, @RequestParam("remark") String remark); R pileStop(@RequestParam(value = "orderNo") String orderNo, @RequestParam(value = "status") Integer status, @RequestParam(value = "remark") String remark);
} }

View File

@ -11,7 +11,9 @@ public class PileEndOrder {
private Integer status; //状态 (1 成功 2 异常) private Integer status; //状态 (1 成功 2 异常)
private Integer chargingTime; //累计充电时间 private Integer chargingTime; //累计充电时间
private Integer chargingDegree; //充电度数 private Integer chargingDegree; //充电度数
private Integer amountCharged; //已充金额 private String amountCharged; //已充金额
private String powerPrice;//电费
private String servicePrice;//服务费
private String erroRemark; //备注 private String erroRemark; //备注
@ -85,14 +87,34 @@ public class PileEndOrder {
this.erroRemark = erroRemark; this.erroRemark = erroRemark;
} }
public Integer getAmountCharged() { public String getAmountCharged() {
return amountCharged; return amountCharged;
} }
public void setAmountCharged(Integer amountCharged) { public void setAmountCharged(String amountCharged) {
this.amountCharged = amountCharged; this.amountCharged = amountCharged;
} }
public String getPowerPrice() {
return powerPrice;
}
public void setPowerPrice(String powerPrice) {
this.powerPrice = powerPrice;
}
public String getServicePrice() {
return servicePrice;
}
public void setServicePrice(String servicePrice) {
this.servicePrice = servicePrice;
}
} }

View File

@ -11,15 +11,17 @@ import com.xhpc.common.dto.PileEndOrder;
import com.xhpc.common.redis.service.RedisService; import com.xhpc.common.redis.service.RedisService;
import com.xhpc.common.util.ConnectionRabbitMQUtil; import com.xhpc.common.util.ConnectionRabbitMQUtil;
import com.xhpc.order.domain.HxpcChargeOrder; import com.xhpc.order.domain.HxpcChargeOrder;
import com.xhpc.order.domain.XhpcHistoryOrder;
import com.xhpc.order.service.IHxpcChargeOrderService; import com.xhpc.order.service.IHxpcChargeOrderService;
import com.xhpc.order.service.IXhpcHistoryOrderService; import com.xhpc.order.service.IXhpcHistoryOrderService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -40,6 +42,8 @@ public class HxpcPileOrderController extends BaseController {
private PileOrderService pileOrderService; private PileOrderService pileOrderService;
/** /**
* 测试 * 测试
*/ */
@ -60,7 +64,7 @@ public class HxpcPileOrderController extends BaseController {
* @return * @return
*/ */
@GetMapping("/chargeOrder/pileStartup") @GetMapping("/chargeOrder/pileStartup")
public R pileStartup(String orderNo, Integer status, String remark) { public R pileStartup(@RequestParam(value = "orderNo")String orderNo, @RequestParam(value = "status")Integer status,@RequestParam(value = "remark") String remark) {
//解析订单编号 //解析订单编号
String s = orderNo.split("\\.")[0]; String s = orderNo.split("\\.")[0];
String s1 = s.split(":")[1]; String s1 = s.split(":")[1];
@ -92,7 +96,7 @@ public class HxpcPileOrderController extends BaseController {
* @return * @return
*/ */
@GetMapping("/chargeOrder/pileStop") @GetMapping("/chargeOrder/pileStop")
public R pileStop(String orderNo, Integer status, String remark) { public R pileStop(@RequestParam(value = "orderNo")String orderNo, @RequestParam(value = "status")Integer status,@RequestParam(value = "remark") String remark) {
//解析订单编号 //解析订单编号
String s = orderNo.split("\\.")[0]; String s = orderNo.split("\\.")[0];
String s1 = s.split(":")[1]; String s1 = s.split(":")[1];
@ -132,6 +136,7 @@ public class HxpcPileOrderController extends BaseController {
* 桩订单结束回调 * 桩订单结束回调
* *
*/ */
@Transactional
@GetMapping("/pileEndOrder") @GetMapping("/pileEndOrder")
public R pileEndOrder(@RequestBody PileEndOrder pileEndOrder) { public R pileEndOrder(@RequestBody PileEndOrder pileEndOrder) {
@ -148,62 +153,96 @@ public class HxpcPileOrderController extends BaseController {
hxpcChargeOrder.setEndTime(date); hxpcChargeOrder.setEndTime(date);
hxpcChargeOrder.setChargingTime(pileEndOrder.getChargingTime().toString()); hxpcChargeOrder.setChargingTime(pileEndOrder.getChargingTime().toString());
hxpcChargeOrder.setChargingDegree(pileEndOrder.getChargingDegree().toString()); hxpcChargeOrder.setChargingDegree(pileEndOrder.getChargingDegree().toString());
hxpcChargeOrder.setAmountCharged(pileEndOrder.getAmountCharged().toString()); hxpcChargeOrder.setAmountCharged(pileEndOrder.getAmountCharged());
hxpcChargeOrder.setErroRemark(pileEndOrder.getErroRemark()); hxpcChargeOrder.setErroRemark(pileEndOrder.getErroRemark());
hxpcChargeOrderService.updateXhpcChargeOrder(hxpcChargeOrder);
//历史订单 //历史订单
Long userId =hxpcChargeOrder.getUserId();
//生成一条历史订单
XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
Map<String, Object> userMessage = hxpcChargeOrderService.getUserMessage(userId);
if(userMessage ==null || userMessage.get("balance") ==null){
//订单异常
hxpcChargeOrder.setStatus(2);
//异常原因
hxpcChargeOrder.setErroRemark("桩异常:"+pileEndOrder.getErroRemark()+">>>>用户id:"+userId+"为空");
}
BigDecimal balance = new BigDecimal(userMessage.get("balance").toString());
//总金额
BigDecimal money = new BigDecimal(pileEndOrder.getAmountCharged());
//总电费
BigDecimal powerPrice = new BigDecimal(pileEndOrder.getPowerPrice());
//总服务费
BigDecimal servicePrice = new BigDecimal(pileEndOrder.getServicePrice());
//电站活动抵扣--抵扣的总金额
BigDecimal promotionDiscount = new BigDecimal(0);
//实际价格-用户支付的钱
BigDecimal actPrice =new BigDecimal(0);
// Date date = new Date();
// //获取实时订单 String state ="";
// Map<String, Object> cacheMap = redisService.getCacheMap("order:"+serialNumber); BigDecimal discount =new BigDecimal(0);
// JSONArray st = (JSONArray)cacheMap.get("realtimeDataList"); //判断是C端用户还是流量端用户
// System.out.println(st.toString()); if(hxpcChargeOrder.getSource() ==0){
// CacheRealtimeData cacheRealtimeData = JSON.toJavaObject(st.getJSONObject(0), CacheRealtimeData.class); //用户第几次充电
// int count = hxpcChargeOrderService.getCount(userId);
// //用户第几次充电 if(count==0){
// int count = iHxpcChargeOrderService.getCount(userId); //活动折扣
// String state =""; Map<String, Object> promotion = hxpcChargeOrderService.getPromotion();
// String discount =""; if(promotion !=null){
// if(count==0){ //state 1.总金额 2.电费 3.服务费 discount 折扣率
// //活动折扣 state = promotion.get("state").toString();
// Map<String, Object> promotion = iHxpcChargeOrderService.getPromotion(); discount = (BigDecimal)promotion.get("discount");
// if(promotion !=null){ }
// //state 1.总金额 2.金额 3.服务费 discount 折扣率 }
// state = promotion.get("state").toString(); if(!"".equals(state)){
// discount = promotion.get("discount").toString(); //没有活动
// } if("1".equals(state)){
// } promotionDiscount=money.multiply(balance);
// actPrice = money.subtract(promotionDiscount);
// //生成一条历史订单 }else if("2".equals(state)){
// XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
// xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId()); }
// xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId()); }
// xhpcHistoryOrder.setUserId(userId);
// xhpcHistoryOrder.setTerminalId(hxpcChargeOrder.getTerminalId());
// xhpcHistoryOrder.setSerialNumber(hxpcChargeOrder.getSerialNumber());
// xhpcHistoryOrder.setStartSoc(hxpcChargeOrder.getStartSoc());
// xhpcHistoryOrder.setReconciliationStatus(0);
// xhpcHistoryOrder.setSortingStatus(0);
// xhpcHistoryOrder.setType(1);
// xhpcHistoryOrder.setStatus(0);
// xhpcHistoryOrder.setDelFlag(0);
// xhpcHistoryOrder.setCreateTime(date);
// //订单总价---运维服务费抽成
// //结束时soc
// xhpcHistoryOrderService.insert(xhpcHistoryOrder);
//
// //充电订单 --结束soc充电时长充电度数
// hxpcChargeOrder.setEndTime(date);
//
// //实时数据存入MYsqlsoc电流电压
}
xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId());
xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId());
xhpcHistoryOrder.setUserId(userId);
xhpcHistoryOrder.setTerminalId(hxpcChargeOrder.getTerminalId());
xhpcHistoryOrder.setSerialNumber(hxpcChargeOrder.getSerialNumber());
xhpcHistoryOrder.setStartSoc(hxpcChargeOrder.getStartSoc());
xhpcHistoryOrder.setReconciliationStatus(0);
xhpcHistoryOrder.setSortingStatus(0);
xhpcHistoryOrder.setType(1);
xhpcHistoryOrder.setStatus(0);
xhpcHistoryOrder.setDelFlag(0);
xhpcHistoryOrder.setCreateTime(date);
//订单总价---运维服务费抽成
//结束时soc
// xhpcHistoryOrderService.insert(xhpcHistoryOrder);
// hxpcChargeOrderService.updateXhpcChargeOrder(hxpcChargeOrder);
return R.ok(); return R.ok();
} }

View File

@ -72,4 +72,11 @@ public interface IHxpcChargeOrderService {
* @return * @return
*/ */
int updateXhpcChargeOrder(HxpcChargeOrder hxpcChargeOrder); int updateXhpcChargeOrder(HxpcChargeOrder hxpcChargeOrder);
/**
* appUserId 查询用户信息
* @param userId
* @return
*/
Map<String,Object> getUserMessage(Long userId);
} }

View File

@ -117,7 +117,7 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
return AjaxResult.error(1104, "无效的终端编号"); return AjaxResult.error(1104, "无效的终端编号");
} }
//余额 //余额
String balance = userMessage.get("balance").toString(); String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString();
//启动充电 //启动充电
StartChargingData startChargingData = new StartChargingData(); StartChargingData startChargingData = new StartChargingData();
//订单流水号 终端号+年月日时分秒+自增4位 共32位 //订单流水号 终端号+年月日时分秒+自增4位 共32位
@ -127,8 +127,11 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
String orderNo = serialNumber + format + SeqUtil.seqDec("gun:" + serialNumber + ".seqdec"); String orderNo = serialNumber + format + SeqUtil.seqDec("gun:" + serialNumber + ".seqdec");
startChargingData.setOrderNo(orderNo); startChargingData.setOrderNo(orderNo);
if(userMessage.get("phone") !=null){
startChargingData.setTel(userMessage.get("phone").toString());
}
startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber()); startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber());
startChargingData.setGunId(xhpcTerminal.getSerialNumber()); startChargingData.setGunId(xhpcTerminal.getSerialNumber().substring(14));
startChargingData.setBalance(Double.valueOf(balance).intValue()); startChargingData.setBalance(Double.valueOf(balance).intValue());
startChargingData.setVersion("0A"); startChargingData.setVersion("0A");
R r1 = powerPileService.startCharging(startChargingData); R r1 = powerPileService.startCharging(startChargingData);
@ -199,4 +202,9 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
return hxpcChargeOrderMapper.updateXhpcChargeOrder(hxpcChargeOrder); return hxpcChargeOrderMapper.updateXhpcChargeOrder(hxpcChargeOrder);
} }
@Override
public Map<String, Object> getUserMessage(Long userId){
return hxpcChargeOrderMapper.getUserMessage(userId);
}
} }

View File

@ -84,6 +84,7 @@
select select
app_user_id as appUserId, app_user_id as appUserId,
balance as balance, balance as balance,
phone as phone,
is_refund_application as isRefundApplication is_refund_application as isRefundApplication
from xhpc_app_user from xhpc_app_user
where del_flag=0 and app_user_id=#{userId} where del_flag=0 and app_user_id=#{userId}