Commit 5ecb76d4 authored by zhangzc's avatar zhangzc

修改refreshTime没有生成的bug

添加支付接口
parent ff59b294
...@@ -62,7 +62,7 @@ public class TokenComponent { ...@@ -62,7 +62,7 @@ public class TokenComponent {
private AppLoginService appLoginService; private AppLoginService appLoginService;
/** /**
* description 创建司机Token信息 * description 创建Token信息
* param [tokenInfoPojo, driverAccountInfoPojo] * param [tokenInfoPojo, driverAccountInfoPojo]
* return void * return void
* author Administrator * author Administrator
...@@ -93,6 +93,38 @@ public class TokenComponent { ...@@ -93,6 +93,38 @@ public class TokenComponent {
redisComponent.set(cacheKey, tokenInfoPojo.toString(), this.accessTokenValidTime * TOKEN_TIME); redisComponent.set(cacheKey, tokenInfoPojo.toString(), this.accessTokenValidTime * TOKEN_TIME);
} }
/**
* description 刷新Token信息
* param [tokenInfoPojo, driverAccountInfoPojo]
* return void
* author Administrator
* createTime 2020/06/04 09:52
**/
public void refreshTokenInfo(TokenInfoPojo tokenInfoPojo) {
// 构建Token信息
tokenInfoPojo.setIp(ReqUtils.getHttpClientIp());
tokenInfoPojo.setSn(ReqUtils.getRequestHeader("mobileId"));
tokenInfoPojo.setDeviceType(Integer.parseInt(ReqUtils.getRequestHeader("requestSource")));
tokenInfoPojo.setOsType(ReqUtils.getRequestHeader("osType"));
tokenInfoPojo.setOsVersion(ReqUtils.getRequestHeader("osVer"));
tokenInfoPojo.setAppVersion(ReqUtils.getRequestHeader("cVer"));
tokenInfoPojo.setAccountType(Integer.parseInt(ReqUtils.getRequestHeader("accountType")));
String accessToken = AesUtils.aesEncrypt(this.getAccessTokenOriginalContent(tokenInfoPojo), AES_KEY);
tokenInfoPojo.setAccessToken(accessToken);
String refreshToken = AesUtils.aesEncrypt(this.getRefreshTokenOriginalContent(tokenInfoPojo), AES_KEY);
tokenInfoPojo.setRefreshToken(refreshToken);
Date refreshTime = new Date();
tokenInfoPojo.setRefreshTime(refreshTime.getTime());
Date accessTokenValidTime = DateUtils.plusDays(refreshTime, this.accessTokenValidTime);
Date refreshTokenValidTime = DateUtils.plusDays(refreshTime, this.refreshTokenValidTime);
tokenInfoPojo.setAccessTokenValidTime(accessTokenValidTime.getTime());
tokenInfoPojo.setRefreshTokenValidTime(refreshTokenValidTime.getTime());
// 缓存Token信息
String cacheKey = this.getTokenInfoCacheKey(tokenInfoPojo.getAccount(), tokenInfoPojo.getAccountType());
redisComponent.set(cacheKey, tokenInfoPojo.toString(), this.accessTokenValidTime * TOKEN_TIME);
}
/** /**
* description 校验Token是否过期 * description 校验Token是否过期
* param [accessToken] * param [accessToken]
......
package com.esv.freight.app.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.feign.PayInterface
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/03 16:50
* @version:1.0
*/
@FeignClient(value = "freight-customer-service")
public interface PayInterface {
/**
* 创建支付订单
* @param bodyJson
* @return
*/
@PostMapping(value = "customer/goodsowner/pay/createPayOrder")
JSONObject createPayOrder(JSONObject bodyJson);
}
...@@ -30,18 +30,6 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -30,18 +30,6 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
@Autowired @Autowired
private TokenComponent tokenComponent; private TokenComponent tokenComponent;
@Autowired
private RedisComponent redisComponent;
private void createToken(AppLoginEntity entity) {
if(entity == null) {
return;
}
entity.setAccessToken(UUID.randomUUID().toString().replaceAll("-", ""));
entity.setRefreshToken(UUID.randomUUID().toString().replaceAll("-", ""));
}
@Override @Override
public LoginVO driverLogin(DriverAccountInfoPojo driverAccountInfoPojo) { public LoginVO driverLogin(DriverAccountInfoPojo driverAccountInfoPojo) {
// 1:初始化Token // 1:初始化Token
...@@ -59,6 +47,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -59,6 +47,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN); appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN);
appLoginEntity.setPhone(tokenInfoPojo.getAccount()); appLoginEntity.setPhone(tokenInfoPojo.getAccount());
appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime())); appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime()));
appLoginEntity.setRefreshTime(appLoginEntity.getLoginTime());
appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime())); appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime()));
appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime())); appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime()));
...@@ -92,6 +81,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -92,6 +81,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN); appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN);
appLoginEntity.setPhone(tokenInfoPojo.getAccount()); appLoginEntity.setPhone(tokenInfoPojo.getAccount());
appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime())); appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime()));
appLoginEntity.setRefreshTime(appLoginEntity.getLoginTime());
appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime())); appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime()));
appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime())); appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime()));
...@@ -147,7 +137,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -147,7 +137,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
TokenInfoPojo tokenInfoPojo = new TokenInfoPojo(); TokenInfoPojo tokenInfoPojo = new TokenInfoPojo();
BeanUtils.copyProperties(pojo, tokenInfoPojo); BeanUtils.copyProperties(pojo, tokenInfoPojo);
this.tokenComponent.generateTokenInfo(tokenInfoPojo); this.tokenComponent.refreshTokenInfo(tokenInfoPojo);
AppLoginEntity record = this.baseMapper.selectOne(new QueryWrapper<AppLoginEntity>().lambda() AppLoginEntity record = this.baseMapper.selectOne(new QueryWrapper<AppLoginEntity>().lambda()
.eq(AppLoginEntity::getAccountType, tokenInfoPojo.getAccountType()) .eq(AppLoginEntity::getAccountType, tokenInfoPojo.getAccountType())
...@@ -157,7 +147,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity ...@@ -157,7 +147,7 @@ public class AppLoginServiceImpl extends ServiceImpl<AppLoginDao, AppLoginEntity
BeanUtils.copyProperties(tokenInfoPojo, appLoginEntity); BeanUtils.copyProperties(tokenInfoPojo, appLoginEntity);
appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN); appLoginEntity.setLoginStatus(AccountConstants.ACCOUNT_STATUS_LOGIN);
appLoginEntity.setPhone(tokenInfoPojo.getAccount()); appLoginEntity.setPhone(tokenInfoPojo.getAccount());
appLoginEntity.setLoginTime(new Date(tokenInfoPojo.getLoginTime())); appLoginEntity.setRefreshTime(new Date(tokenInfoPojo.getRefreshTime()));
appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime())); appLoginEntity.setAccessTokenValidTime(new Date(tokenInfoPojo.getAccessTokenValidTime()));
appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime())); appLoginEntity.setRefreshTokenValidTime(new Date(tokenInfoPojo.getRefreshTokenValidTime()));
appLoginEntity.setId(record.getId()); appLoginEntity.setId(record.getId());
......
...@@ -5,14 +5,18 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,14 +5,18 @@ import com.alibaba.fastjson.JSONObject;
import com.esv.freight.app.common.response.EResponse; import com.esv.freight.app.common.response.EResponse;
import com.esv.freight.app.common.util.FeignUtils; import com.esv.freight.app.common.util.FeignUtils;
import com.esv.freight.app.common.validator.groups.ValidatorDetail; import com.esv.freight.app.common.validator.groups.ValidatorDetail;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList; import com.esv.freight.app.common.validator.groups.ValidatorList;
import com.esv.freight.app.feign.OwnerBillInterface; import com.esv.freight.app.feign.OwnerBillInterface;
import com.esv.freight.app.feign.PayInterface;
import com.esv.freight.app.module.account.pojo.DriverAccountInfoPojo; import com.esv.freight.app.module.account.pojo.DriverAccountInfoPojo;
import com.esv.freight.app.module.bill.form.BillQueryForm; import com.esv.freight.app.module.bill.form.BillQueryForm;
import com.esv.freight.app.module.bill.form.OwnerPayForm;
import com.esv.freight.app.module.bill.pojo.OwnerBillDetailPojo; import com.esv.freight.app.module.bill.pojo.OwnerBillDetailPojo;
import com.esv.freight.app.module.bill.vo.BillDetailVO; import com.esv.freight.app.module.bill.vo.BillDetailVO;
import com.esv.freight.app.module.bill.vo.BillListItemVO; import com.esv.freight.app.module.bill.vo.BillListItemVO;
import com.esv.freight.app.module.bill.vo.BillListVO; import com.esv.freight.app.module.bill.vo.BillListVO;
import com.esv.freight.app.module.bill.vo.PayVO;
import com.esv.freight.app.module.evaluate.form.OwnerEvaluateForm; import com.esv.freight.app.module.evaluate.form.OwnerEvaluateForm;
import com.esv.freight.app.module.evaluate.vo.EvaluateListItemVO; import com.esv.freight.app.module.evaluate.vo.EvaluateListItemVO;
import com.esv.freight.app.module.evaluate.vo.EvaluateListVO; import com.esv.freight.app.module.evaluate.vo.EvaluateListVO;
...@@ -44,14 +48,45 @@ import java.util.List; ...@@ -44,14 +48,45 @@ import java.util.List;
public class OwnerBillController { public class OwnerBillController {
private OwnerBillInterface ownerBillInterface; private OwnerBillInterface ownerBillInterface;
private PayInterface payInterface;
@Autowired @Autowired
public OwnerBillController(OwnerBillInterface ownerBillInterface) { public OwnerBillController(OwnerBillInterface ownerBillInterface, PayInterface payInterface) {
this.ownerBillInterface = ownerBillInterface; this.ownerBillInterface = ownerBillInterface;
this.payInterface = payInterface;
} }
/** /**
* description 获取对账详情 * description 创建支付订单
* param complaintForm
* return com.esv.freight.common.response.EResponse
* author 张志臣
* createTime 2020/06/03 17:00
**/
@PostMapping("/createPayOrder")
public EResponse createPayOrder(@RequestBody(required=false) @Validated(ValidatorInsert.class) OwnerPayForm ownerPayForm) {
// 调用确认账单接口
JSONObject reqJson = new JSONObject();
reqJson.put("customerId", ownerPayForm.getCustomerId());
reqJson.put("billId", ownerPayForm.getBillNo());
reqJson.put("billDesc", "应付账单");
reqJson.put("txnAmt", ownerPayForm.getTxnAmt());
log.info(reqJson.toJSONString());
JSONObject result = payInterface.createPayOrder(reqJson);
log.info(result.toJSONString());
if(!FeignUtils.isFeignSuccess(result)) {
return FeignUtils.getFeignEResponse(result);
}
PayVO payVO = new PayVO();
payVO.setTn(result.getJSONObject("data").getString("tn"));
return EResponse.ok(payVO);
}
/**
* description 确认对账
* param complaintForm * param complaintForm
* return com.esv.freight.common.response.EResponse * return com.esv.freight.common.response.EResponse
* author 张志臣 * author 张志臣
......
package com.esv.freight.app.module.bill.form;
import com.esv.freight.app.common.validator.groups.ValidatorInsert;
import com.esv.freight.app.common.validator.groups.ValidatorList;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.math.BigDecimal;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.bill.form.OwnerPayForm
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/03 16:50
* @version:1.0
*/
@Data
public class OwnerPayForm {
/**
* 账号ID
*/
@Positive(message = "参数userId不合法", groups = {ValidatorInsert.class})
@NotNull(message = "参数userId不能为空", groups = {ValidatorInsert.class})
private Long customerId;
/**
* 账单号
*/
@NotBlank(message = "参数billNo不能为空", groups = {ValidatorInsert.class})
private String billNo;
/**
* 交易金额
*/
@Positive(message = "参数txnAmt不合法", groups = {ValidatorInsert.class})
@NotNull(message = "参数txnAmt不能为空", groups = {ValidatorInsert.class})
private BigDecimal txnAmt;
}
package com.esv.freight.app.module.bill.vo;
import lombok.Data;
/**
* @description:
* @project: freight-app-service
* @name: com.esv.freight.app.module.bill.vo.PayVO
* @author: 张志臣
* @email: zhangzhichen@esvtek.com
* @createTime: 2020/06/03 17:00
* @version:1.0
*/
@Data
public class PayVO {
/**
* 流水号
**/
private String tn;
}
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