充值成功增加调用桩余额下发接口
This commit is contained in:
parent
aeacac3ea6
commit
6aec7b24dd
@ -5,7 +5,6 @@ import javax.validation.constraints.NotBlank;
|
|||||||
|
|
||||||
public class StartChargingData {
|
public class StartChargingData {
|
||||||
|
|
||||||
@NotBlank(message = "订单流水号不能为空")
|
|
||||||
private String orderNo; //交易流水号
|
private String orderNo; //交易流水号
|
||||||
@NotBlank(message = "桩号不能为空")
|
@NotBlank(message = "桩号不能为空")
|
||||||
private String pileNo; //桩号
|
private String pileNo; //桩号
|
||||||
|
|||||||
@ -58,14 +58,12 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTitleId" resultType="map">
|
<select id="selectTitleId" resultType="map">
|
||||||
|
|
||||||
select help_id as helpId,title
|
select help_id as helpId,title
|
||||||
from xhpc_help
|
from xhpc_help
|
||||||
where type=#{type}
|
where type=#{type} and status=0 and del_flag=0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDetails" resultType="map">
|
<select id="selectDetails" resultType="map">
|
||||||
|
|
||||||
select title,cast(content as char) as content
|
select title,cast(content as char) as content
|
||||||
from xhpc_help
|
from xhpc_help
|
||||||
where help_id=#{helpId}
|
where help_id=#{helpId}
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
package com.xhpc.payment.controller;
|
package com.xhpc.payment.controller;
|
||||||
|
|
||||||
|
import com.xhpc.common.api.PowerPileService;
|
||||||
import com.xhpc.common.core.constant.HttpStatus;
|
import com.xhpc.common.core.constant.HttpStatus;
|
||||||
import com.xhpc.common.core.constant.StatusConstants;
|
import com.xhpc.common.core.constant.StatusConstants;
|
||||||
|
import com.xhpc.common.core.domain.R;
|
||||||
import com.xhpc.common.core.utils.StringUtils;
|
import com.xhpc.common.core.utils.StringUtils;
|
||||||
import com.xhpc.common.core.utils.WXPayUtil;
|
import com.xhpc.common.core.utils.WXPayUtil;
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import com.xhpc.common.data.down.StartChargingData;
|
||||||
import com.xhpc.payment.domain.XhpcAppUser;
|
import com.xhpc.payment.domain.XhpcAppUser;
|
||||||
import com.xhpc.payment.domain.XhpcRechargeOrder;
|
import com.xhpc.payment.domain.XhpcRechargeOrder;
|
||||||
import com.xhpc.payment.domain.XhpcUserAccountStatement;
|
import com.xhpc.payment.domain.XhpcUserAccountStatement;
|
||||||
@ -22,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.servlet.ServletInputStream;
|
import javax.servlet.ServletInputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -60,6 +64,15 @@ public class WxPaymentController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PowerPileService powerPileService;
|
||||||
|
|
||||||
|
private int number;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init(){
|
||||||
|
number =1;
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/payment")
|
@PostMapping("/payment")
|
||||||
@ApiOperation(value = "微信支付")
|
@ApiOperation(value = "微信支付")
|
||||||
@ -349,10 +362,17 @@ public class WxPaymentController {
|
|||||||
Map<String, Object> appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(xhpcRechargeOrder.getUserId());
|
Map<String, Object> appUserInfo = xhpcUserAccountStatementMapper.appUserInfo(xhpcRechargeOrder.getUserId());
|
||||||
if (StringUtils.isNotNull(appUserInfo)) {
|
if (StringUtils.isNotNull(appUserInfo)) {
|
||||||
String balance = StringUtils.valueOf(appUserInfo.get("balance"));
|
String balance = StringUtils.valueOf(appUserInfo.get("balance"));
|
||||||
|
BigDecimal money = BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount());
|
||||||
|
//判断用户是否在充电中
|
||||||
|
String serialMumber = xhpcUserAccountStatementMapper.getUserHistotyChargeOrder(xhpcRechargeOrder.getUserId());
|
||||||
|
if(!"".equals(serialMumber) && serialMumber !=null){
|
||||||
|
//充电中
|
||||||
|
postRefreshBalance(money, serialMumber);
|
||||||
|
}
|
||||||
//增加用户余额
|
//增加用户余额
|
||||||
XhpcAppUser xhpcAppUser = new XhpcAppUser();
|
XhpcAppUser xhpcAppUser = new XhpcAppUser();
|
||||||
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
|
xhpcAppUser.setAppUserId(xhpcRechargeOrder.getUserId());
|
||||||
xhpcAppUser.setBalance(BigDecimal.valueOf(Double.valueOf(balance)).add(xhpcRechargeOrder.getAmount()));
|
xhpcAppUser.setBalance(money);
|
||||||
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
|
xhpcUserAccountStatementMapper.updateAppUserBalance(xhpcAppUser);
|
||||||
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
|
XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement();
|
||||||
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
|
xhpcUserAccountStatement.setType(StatusConstants.FLOWING_WATER_RECHARGE_TYPE);
|
||||||
@ -365,6 +385,19 @@ public class WxPaymentController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void postRefreshBalance(BigDecimal money, String serialMumber) {
|
||||||
|
StartChargingData startChargingData =new StartChargingData();
|
||||||
|
startChargingData.setPileNo(serialMumber.substring(0,16));
|
||||||
|
startChargingData.setGunId(serialMumber.substring(16));
|
||||||
|
String s1 =money.multiply(new BigDecimal(100)).toString();
|
||||||
|
startChargingData.setBalance(Double.valueOf(s1).intValue());
|
||||||
|
R r = powerPileService.refreshBalance(startChargingData);
|
||||||
|
if(r.getCode() !=200){
|
||||||
|
//创建定时任务
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回调Api
|
* 回调Api
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -63,4 +63,13 @@ public interface XhpcUserAccountStatementMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Map<String, Object>> list(@Param("appUserId") Long appUserId);
|
public List<Map<String, Object>> list(@Param("appUserId") Long appUserId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实时订单获取终端号
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getUserHistotyChargeOrder(@Param("userId") Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -171,4 +171,10 @@
|
|||||||
</if>
|
</if>
|
||||||
ORDER BY xuas.create_time DESC
|
ORDER BY xuas.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getUserHistotyChargeOrder" resultType="String">
|
||||||
|
select
|
||||||
|
serial_number as serialMumber
|
||||||
|
from xhpc_terminal
|
||||||
|
where terminal_id =(select terminal_id from xhpc_charge_order where user_id = #{userId} and status=0 and del_flag =0 limit 1)
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user