修改订单,修改退款,修改用户基本信息

This commit is contained in:
yuyang 2022-02-10 10:33:55 +08:00
parent 6168747570
commit b471094fc5
15 changed files with 84 additions and 98 deletions

View File

@ -36,7 +36,7 @@ public class XhpcIcCardInfo implements Serializable {
/**
* 用户id
*/
private Integer userId;
private Long userId;
/**
* 用户账户
@ -46,7 +46,7 @@ public class XhpcIcCardInfo implements Serializable {
/**
* 用户类型0 C端用户 1 流量方用户 2社区用户 3B端用户
*/
private Long userType;
private Integer userType;
/**
* 用户姓名
@ -83,6 +83,8 @@ public class XhpcIcCardInfo implements Serializable {
*/
private Long delFlag;
private String tenantId;
private static final long serialVersionUID = 1L;
}

View File

@ -6,7 +6,9 @@ import com.xhpc.card.pojo.*;
import com.xhpc.card.service.IXhpcCardService;
import com.xhpc.card.utils.MyPagingUtil;
import com.xhpc.common.api.CardHistoryOrderService;
import com.xhpc.common.core.constant.Constants;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.domain.IccardInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -43,50 +45,6 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
@Resource
private XhpcCustomersPersonnelMapper xhpcCustomersPersonnelMapper;
///**
// * 卡启动充电判断
// *
// * @param cardno
// * @param serialNumber
// * @return
// */
//@Override
//public R cardStartup(String cardno, String serialNumber) {
//
// IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno);
// if(iccardInfo !=null){
// if(iccardInfo.getCardtype()==0){
// return R.fail(Constants.OFFLINE_CARD);
// }
// if(iccardInfo.getStatus()==0){
// return R.fail(Constants.ZERO_CARD);
// }
// if(iccardInfo.getStatus()==2){
// return R.fail(Constants.TWO_CARD);
// }
// if(iccardInfo.getStatus()==3){
// return R.fail(Constants.THREE_CARD);
// }
// if(iccardInfo.getStatus()==4){
// return R.fail(Constants.FOUR_CARD);
// }
// }else{
// return R.fail(Constants.LNVALID_CARD);
// }
// //查询卡号对应的用户
// XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString());
// if (xhpcIcCardInfo == null) {
// return R.fail(Constants.LNVALID_USER);
// }
// Long userId = xhpcIcCardInfo.getUserId();
// Integer userType = xhpcIcCardInfo.getUserType();
// String tenantId = xhpcIcCardInfo.getTenantId();
// Integer type = 1;
// String grantOperator = xhpcIcCardInfo.getGrantOperatorId();
// return cardHistoryOrderService.cardStartup(userId, serialNumber, userType, tenantId, type, grantOperator);
//}
@Override
public R cardStartup(String cardno, String serialNumber,String rateModelId) {
@ -122,7 +80,7 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
Integer userType=xhpcIcCardInfo.getUserType();
String tenantId=xhpcIcCardInfo.getTenantId();
Integer type =1;//改成卡授权的类型
String grantOperator=xhpcIcCardInfo.getGrantOperatorId();//改成卡授权的运营商
String grantOperator=iccardInfo.getCorpno();//改成卡授权的运营商
return cardHistoryOrderService.cardStartup(userId, serialNumber, userType,tenantId,type,grantOperator,rateModelId);
}
@ -349,9 +307,9 @@ public class XhpcCardServiceImpl implements IXhpcCardService {
xhpcIcCardInfo.setUseStatus(1L);
xhpcIcCardInfo.setCreateTime(new Date());
TIccardInfo tIccardInfo = tIccardInfoMapper.selectByPrimaryKey(bindCardInfo.getCardRecordId());
xhpcIcCardInfo.setUserId(tIccardInfo.getUserindex());
xhpcIcCardInfo.setUserId(Long.valueOf(tIccardInfo.getUserindex()));
xhpcIcCardInfo.setUserAccount(bindCardInfo.getUserAccount());
xhpcIcCardInfo.setUserType(Long.valueOf(bindCardInfo.getUserType()));
xhpcIcCardInfo.setUserType(bindCardInfo.getUserType());
xhpcCardMapper.insertSelective(xhpcIcCardInfo);
return R.ok();
}

View File

@ -6,6 +6,7 @@ import com.xhpc.common.core.domain.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
@ -17,5 +18,5 @@ import java.util.Map;
public interface RefundOrderService {
@PostMapping("/refund/order/orderCheckOut")
R sendNotice(@RequestBody Map<String, Object> map);
R sendNotice(@RequestParam(value = "amount") String amount,@RequestParam(value = "openid") String openid,@RequestParam(value = "source") Integer source,@RequestParam(value = "type") String type,@RequestParam(value = "userId") String userId,@RequestParam(value = "tenantId")String tenantId,@RequestParam(value = "remark")String remark);
}

View File

@ -22,9 +22,10 @@ public class RefundOrderFallbackFactory implements FallbackFactory<RefundOrderSe
logger.error("申请退款服务调用失败:{} //fallback", cause.getMessage());
return new RefundOrderService() {
@Override
public R sendNotice(Map<String, Object> map) {
public R sendNotice(String amount, String openid, Integer source, String type, String userId,String tenantId,String remark) {
return R.fail("自动申请退款失败:" + cause.getMessage());
}
};
}
}

View File

@ -215,9 +215,8 @@ public class XhpcPileOrderController extends BaseController {
redisService.setCacheMap("realTimeTenantId:"+message,map);
webSocketService.getMessage(message,json.toString());
//消息对了内容
logger.info("桩实时数据发送WebSocket成功>>>>>orderNo" + orderNo);
logger.info("桩实时数据发送WebSocket成功>>>>>orderNo" + orderNo+"websocket :"+message);
}
} catch (Exception e) {
Map<String, Object> map = new HashMap<>();
map.put("code", 500);

View File

@ -350,7 +350,7 @@ public class XhpcStatisticsController extends BaseController {
* @param source 订单来源0 C端用户 1 流量方用户 2社区用户 3B端用户
* @return
*/
@GetMapping("/getMechanismPage/export")
@PostMapping("/getMechanismPage/export")
public void getMechanismExport(HttpServletRequest request,HttpServletResponse response,String chargingStationIds,Long internetUserId, Long operatorId,String startTime, String endTime, @RequestParam("userId") Long userId, @RequestParam("type")Integer type,@RequestParam("source")Integer source)throws IOException
{
xhpcStatisticsService.getMechanismExport(request,response,chargingStationIds,internetUserId,operatorId,startTime,endTime,userId,type,source);

View File

@ -662,6 +662,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date,source);
map.put("userId",userId);
map.put("amount",subtract);
map.put("source",xhpcChargeOrder.getSource());
map.put("tenantId",xhpcChargeOrder.getTenantId());
if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){
map.put("openid",userMessage.get("weixinOpenId").toString());
map.put("type",1);
@ -703,7 +705,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
public void run() {
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
refundOrderService.sendNotice(map);
refundOrderService.sendNotice(map.get("subtract").toString(),map.get("openid").toString(),source,map.get("type").toString(),map.get("userId").toString(),xhpcChargeOrder.getTenantId(),map.get("remark").toString());
}
xhpcRealTimeOrderService.addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(), 1);
}

View File

@ -586,7 +586,10 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
}
Map<String, Object> map =new HashMap<>();
map.put("source",xhpcChargeOrder.getSource());
map.put("tenantId",xhpcChargeOrder.getTerminalId());
map.put("tenantId",xhpcChargeOrder.getTenantId());
BigDecimal subtract =new BigDecimal(0);
String openid ="";
String refundType ="";
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
xhpcHistoryOrder.setUserNameEvcs(userMessage.get("phone").toString());
if(UserTypeUtil.USER_TYPE.equals(source)){
@ -601,7 +604,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
}
//扣除用户实际消费金额添加消费记录 剩余的钱
BigDecimal balance1 =new BigDecimal(userMessage.get("balance").toString());
BigDecimal subtract = balance1.subtract(actPrice);
subtract = balance1.subtract(actPrice);
int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId());
if(i==0){
//扣钱失败
@ -614,11 +617,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
map.put("userId",userId);
map.put("amount",subtract);
if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){
map.put("openid",userMessage.get("weixinOpenId").toString());
map.put("type",1);
openid=userMessage.get("weixinOpenId").toString();
refundType="1";
}else{
map.put("openid",userMessage.get("alipayOpenId").toString());
map.put("type",2);
openid=userMessage.get("alipayOpenId").toString();
refundType="2";
}
map.put("remark","充电结算自动申请退款");
}
@ -627,23 +630,35 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
logger.info("<<<<<<<<<<<<<<<<订单结束异步之前>>>>>>>>>>>>>>>>>"+xhpcHistoryOrder.getSerialNumber());
final BigDecimal balance = actPrice;
final String balance2 = subtract.toString();
final String openids =openid;
final String refundTypes =refundType;
// 另起线程处理业务上传redis数据
executorService.execute(new Runnable() {
@Override
public void run() {
try{
Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId());
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
logger.info("<<<<<<<<<<<<<<<<进入自动退款111>>>>>>>>>>>>>>>>>");
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
logger.info("<<<<<<<<<<<<<<<<进入自动退款222>>>>>>>>>>>>>>>>>");
refundOrderService.sendNotice(map);
R r = refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getCode());
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getData());
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getMsg());
}
}
}catch (Exception e){
e.printStackTrace();
logger.info("<<<<<<<<<<<<<<<<自动退款失败>>>>>>>>>>>>>>>>>");
}
try{
Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId());
if(!UserTypeUtil.INSERT_BALANCE.equals(source)){
Map<String, Object> userMassage = xhpcChargeOrderService.getUserMessage(userId);
if(xhpcChargingPile !=null){
logger.info("<<<<<<<<<<<<<<<<进入发送短信>>>>>>>>>>>>>>>>>");
//发送短信
if(userMassage !=null && userMassage.get("phone") !=null){
if("1".equals(xhpcChargingPile.get("type").toString())){
@ -743,9 +758,9 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
//删除redis
//redisService.deleteObject("order:"+orderNo);
//redisService.deleteObject("order:"+orderNo+".lord");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>订单号:>>>"+orderNo+">>>>>");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>订单号:>>>"+orderNo+">>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>订单号:>>>"+orderNo+">>>>>>>>");
}

View File

@ -538,7 +538,7 @@
select charging_pile_id as chargingPileId,
IFNULL(type, '1') as type
from xhpc_charging_pile
where charging_pile_id = (select charging_pile_id from xhpc_terminal where terminal_id = #{terminalId})
where charging_pile_id = (select charging_pile_id from xhpc_terminal where terminal_id = #{terminalId} and del_flag =0) and del_flag =0
</select>
<select id="getXhpcChargeOrderStatus" resultMap="XhpcChargeOrderResult">

View File

@ -451,7 +451,7 @@
END sourceName
from xhpc_statistics_station
where del_flag=0 and type=2
<if test="source !=null">
<if test="source !=null and source !=-1">
and source=#{source}
</if>
<if test="source ==null">

View File

@ -4,6 +4,7 @@ import com.xhpc.common.api.UserTypeService;
import com.xhpc.common.core.annotation.NoRepeatSubmit;
import com.xhpc.common.core.constant.HttpStatus;
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.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
@ -170,53 +171,53 @@ public class XhpcRefundOrderController extends BaseController {
@NoRepeatSubmit
@PostMapping("/orderCheckOut")
@ApiOperation(value = "订单自动退款")
public AjaxResult orderCheckOut(@RequestBody Map<String, Object> map) {
Long userid = Long.valueOf(map.get("userId").toString());
Integer userType = Integer.valueOf(map.get("source").toString());
String tenantId = map.get("tenantId").toString();
public R orderCheckOut(@RequestParam(value = "amount") String amount,@RequestParam(value = "openid") String openid,@RequestParam(value = "source") Integer source,@RequestParam(value = "type") String type,@RequestParam(value = "userId") String userId,@RequestParam(value = "tenantId")String tenantId,@RequestParam(value = "remark")String remark) {
Integer userType = source;
if (UserTypeUtil.CUSTOMERS_TYPE.equals(userType)) {
return AjaxResult.error(HttpStatus.ERROR_STATUS, "大客户不支持退款");
return R.fail("大客户不支持退款");
}
String amount = StringUtils.valueOf(map.get("amount"));
if (StringUtils.isEmpty(amount)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "退款金额不能为空");
return R.fail("退款金额不能为空");
} else {
if (new BigDecimal(1).compareTo(new BigDecimal(amount)) == 1) {
return AjaxResult.error(HttpStatus.NOT_NULL, "退款金额不能少于1元");
return R.fail("退款金额不能少于1元");
}
}
//用户信息id
String userId = StringUtils.valueOf(map.get("userId"));
if (StringUtils.isEmpty(userId)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空");
return R.fail("用户信息不能为空");
}
//openid
String openid = StringUtils.valueOf(map.get("openid"));
if (StringUtils.isEmpty(userId)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空");
return R.fail("用户信息不能为空");
}
String type = StringUtils.valueOf(map.get("type"));
if (StringUtils.isEmpty(type)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "退款渠道不能为空");
return R.fail("退款渠道不能为空");
}
//是否有实时数据
Long userid = Long.valueOf(userId);
int i = iXhpcRefundOrderService.countXhpcRealTimeOrder(userid, userType, tenantId);
if (i > 0) {
return AjaxResult.error(1103, "车辆正在充电,不能退款");
return R.fail("车辆正在充电,不能退款");
}
// 是否有异常订单
int j = iXhpcRefundOrderService.countXhpcChargeOrder(userid, userType, tenantId);
if (j > 0) {
return AjaxResult.error(1103, "你有异常订单未解决,请拨打客服电话进行解决");
return R.fail("你有异常订单未解决,请拨打客服电话进行解决");
}
//生成退款订单
String orderOutNumber = StringUtils.numFormat(userid, Integer.parseInt(type),
StatusConstants.FLOWING_WATER_REFUND_TYPE);
String remark = StringUtils.valueOf(map.get("remark"));
return iXhpcRefundOrderService.addRefundOrder("" + userid, BigDecimal.valueOf(Double.parseDouble(amount)), type,
logger.info("<<<<<<<<<<<<<<<<开始创建退款订单>>>>>>>>>>>>>>>>>");
AjaxResult ajaxResult = iXhpcRefundOrderService.addRefundOrder("" + userid, BigDecimal.valueOf(Double.parseDouble(amount)), type,
orderOutNumber, openid, remark, userType, tenantId);
if("200".equals(ajaxResult.get("code"))){
return R.ok();
}else{
return R.fail(ajaxResult.get("msg"));
}
}

View File

@ -16,7 +16,6 @@ import com.xhpc.common.core.utils.sign.Base64;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.domain.XhpcSettingConfig;
import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.user.service.IXhpcAppUserUserService;
@ -165,7 +164,6 @@ public class XhpcAppUserController extends BaseController {
}
R r = settingConfigService.settingConfig(1, tenantId);
if(r !=null && r.getCode()==200){
XhpcSettingConfig xhpcSettingConfig = (XhpcSettingConfig)r.getData();
Map<String, Object> mapConfig = (Map<String, Object>)r.getData();
String url = "https://api.weixin.qq.com/sns/jscode2session?appid="+mapConfig.get("wxAppId").toString()+"&secret="+mapConfig.get("wxAppSecret").toString()+"&js_code="+ jsCode + "&grant_type=authorization_code";
String result = HttpUtils.get(url);

View File

@ -421,7 +421,7 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
if(user !=null && user.getData() !=null){
Map<String, Object> map = (Map<String, Object>)user.getData();
//发票留言板版本客服电话
String invoice =null;
Integer invoice =null;
if(UserTypeUtil.USER_TYPE.equals(userType)){
invoice = redisService.getCacheObject("global:invoice:" + UserTypeUtil.USER + userid);
}else if(UserTypeUtil.INTERNET_TYPE.equals(userType)){
@ -436,17 +436,21 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
}else{
map.put("invoiceNumber",invoice);
}
String guestbook =null;
Integer guestbook =null;
if(UserTypeUtil.USER_TYPE.equals(userType)){
guestbook = redisService.getCacheObject("userNotReadMessageCount:" + UserTypeUtil.USER_TYPE + ":" + map.get("phone").toString() + ":0:" + loginUser.getTenantId());
guestbook = redisService.getCacheObject("userNotReadMessageCount:"+UserTypeUtil.USER_TYPE + ":" + map.get("phone").toString() + ":0:" + loginUser.getTenantId());
}else if(UserTypeUtil.INTERNET_TYPE.equals(userType)){
guestbook = redisService.getCacheObject("userNotReadMessageCount:" + UserTypeUtil.INTERNET_TYPE + ":" + map.get("phone").toString() + ":0:" + loginUser.getTenantId());
guestbook = redisService.getCacheObject("userNotReadMessageCount:"+UserTypeUtil.INTERNET_TYPE + ":" + map.get("phone").toString() + ":0:" + loginUser.getTenantId());
}else if(UserTypeUtil.COMMUNIT_TYPE.equals(userType)){
guestbook = redisService.getCacheObject("userNotReadMessageCount:" + UserTypeUtil.COMMUNIT_TYPE + ":" + map.get("account").toString() + ":0:" + loginUser.getTenantId());
guestbook = redisService.getCacheObject("userNotReadMessageCount:"+UserTypeUtil.COMMUNIT_TYPE + ":" + map.get("account").toString() + ":0:" + loginUser.getTenantId());
}else{
guestbook = redisService.getCacheObject("userNotReadMessageCount:" + UserTypeUtil.CUSTOMERS_TYPE + ":" + map.get("account").toString() + ":0:" + loginUser.getTenantId());
guestbook = redisService.getCacheObject("userNotReadMessageCount:"+UserTypeUtil.CUSTOMERS_TYPE + ":" + map.get("account").toString() + ":0:" + loginUser.getTenantId());
}
if(guestbook==null){
map.put("guestbook","0");
}else{
map.put("guestbook",guestbook);
}
map.put("version",version);
map.put("servicePhone",servicePhone);
map.put("activity",1);

View File

@ -25,7 +25,7 @@ public class OrderNotificationWebSocketController extends BaseController {
@GetMapping("/orderWebSocket/getMessage")
public R getMessage(@RequestParam String userId, @RequestParam String message){
OrderNotificationWebSocket.sendMessage(userId,message);
logger.info("发送消息成功------->>>>>message"+message);
logger.info("发送用户--->"+userId+"发送消息成功------->>>>>message"+message);
return R.ok();
}

View File

@ -1,6 +1,7 @@
package com.xhpc.wxma.socket;
import com.alibaba.fastjson.JSONObject;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.wxma.domain.WebSocketClient;
import org.springframework.stereotype.Component;
@ -21,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
@Component
@ServerEndpoint(value = "/websocket/{userId}")
public class OrderNotificationWebSocket {
public class OrderNotificationWebSocket extends BaseController {
static final ConcurrentHashMap<String, List<WebSocketClient>> webSocketClientMap= new ConcurrentHashMap<>();
@ -80,6 +81,10 @@ public class OrderNotificationWebSocket {
if(webSocketClientList!=null){
for(WebSocketClient webSocketServer:webSocketClientList){
webSocketServer.getSession().getBasicRemote().sendText(message);
System.out.println("----------------------");
System.out.println("---------userId-------------"+userId);
System.out.println("---------message-------------"+message);
System.out.println("----------------------");
}
}
} catch (IOException e) {