意向金 加盟费 合同签约增加修改+fix 获取 wx token
This commit is contained in:
@@ -189,5 +189,6 @@ public class CommonConstants {
|
|||||||
|
|
||||||
public static final String HD_ENV = "hd";
|
public static final String HD_ENV = "hd";
|
||||||
public static final String ONLINE_ENV = "online";
|
public static final String ONLINE_ENV = "online";
|
||||||
|
public static final String AMOUNT_KEY = "amount:{0}:{1}";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.cool.store.mq.util.HttpRestTemplateService;
|
|||||||
import com.cool.store.utils.RedisUtilPool;
|
import com.cool.store.utils.RedisUtilPool;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -31,7 +32,10 @@ public class WechatRest {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private HttpRestTemplateService httpRestTemplateService;
|
private HttpRestTemplateService httpRestTemplateService;
|
||||||
|
@Value("${weixin.appId}")
|
||||||
|
private String wxAppId;
|
||||||
|
@Value("${weixin.appSecret}")
|
||||||
|
private String wxAppSecret;
|
||||||
/**
|
/**
|
||||||
* 小程序Token 地址
|
* 小程序Token 地址
|
||||||
*/
|
*/
|
||||||
@@ -97,10 +101,24 @@ public class WechatRest {
|
|||||||
responseStr = httpRestTemplateService.postForObject(reqUrl, requestMap, String.class);
|
responseStr = httpRestTemplateService.postForObject(reqUrl, requestMap, String.class);
|
||||||
log.info("WechatRest#getUserPhoneNumber, reqUrl:{}, response:{}", reqUrl, responseStr);
|
log.info("WechatRest#getUserPhoneNumber, reqUrl:{}, response:{}", reqUrl, responseStr);
|
||||||
if(StringUtils.isNotBlank(responseStr)){
|
if(StringUtils.isNotBlank(responseStr)){
|
||||||
return JSONObject.parseObject(responseStr, PhoneInfoDTO.class);
|
PhoneInfoDTO phoneInfoDTO = JSONObject.parseObject(responseStr, PhoneInfoDTO.class);
|
||||||
|
if (phoneInfoDTO != null && "40001".equals(phoneInfoDTO.getErrCode())) {
|
||||||
|
throw new ServiceException(ErrorCodeEnum.WX_ACCESS_TOKEN_INVALID);
|
||||||
|
}
|
||||||
|
return phoneInfoDTO;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取手机号异常", e);
|
log.error("获取手机号异常", e);
|
||||||
|
log.info("重新获取微信token");
|
||||||
|
String cacheAccessToken = "wechat_mini_" + wxAppId;
|
||||||
|
redisUtilPool.delKey(cacheAccessToken);
|
||||||
|
String newAccessToken = getAccessToken(wxAppId, wxAppSecret);
|
||||||
|
reqUrl = String.format(GET_USERPHONENUMBER, newAccessToken);
|
||||||
|
responseStr = httpRestTemplateService.postForObject(reqUrl, requestMap, String.class);
|
||||||
|
log.info("WechatRest#newGetUserPhoneNumber, reqUrl:{}, response:{}", reqUrl, responseStr);
|
||||||
|
if (StringUtils.isNotBlank(responseStr)) {
|
||||||
|
return JSONObject.parseObject(responseStr, PhoneInfoDTO.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public interface LinePayService {
|
|||||||
|
|
||||||
LinePayVO getLinePayInfo(Long lineId,Integer businessType,Long shopId);
|
LinePayVO getLinePayInfo(Long lineId,Integer businessType,Long shopId);
|
||||||
|
|
||||||
Integer updateLinePayInfo(Long lineId, Integer businessType, AmountDTO amount, String userId);
|
Boolean setAmount(Long lineId, String amount);
|
||||||
|
String getAmount(Long lineId);
|
||||||
/**
|
/**
|
||||||
* 跳过缴纳意向金
|
* 跳过缴纳意向金
|
||||||
* @param lineId
|
* @param lineId
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.cool.store.service.impl;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.cool.store.constants.CommonConstants;
|
||||||
import com.cool.store.context.LoginUserInfo;
|
import com.cool.store.context.LoginUserInfo;
|
||||||
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
||||||
import com.cool.store.dao.LineInfoDAO;
|
import com.cool.store.dao.LineInfoDAO;
|
||||||
@@ -23,17 +24,21 @@ import com.cool.store.mapper.LineInfoMapper;
|
|||||||
import com.cool.store.mapper.ShopInfoMapper;
|
import com.cool.store.mapper.ShopInfoMapper;
|
||||||
import com.cool.store.request.LinePaySubmitRequest;
|
import com.cool.store.request.LinePaySubmitRequest;
|
||||||
import com.cool.store.service.LinePayService;
|
import com.cool.store.service.LinePayService;
|
||||||
|
import com.cool.store.utils.RedisUtilPool;
|
||||||
import com.cool.store.utils.poi.DateUtils;
|
import com.cool.store.utils.poi.DateUtils;
|
||||||
import com.cool.store.utils.poi.StringUtils;
|
import com.cool.store.utils.poi.StringUtils;
|
||||||
import com.cool.store.utils.poi.constant.Constants;
|
import com.cool.store.utils.poi.constant.Constants;
|
||||||
import com.cool.store.vo.LinePayVO;
|
import com.cool.store.vo.LinePayVO;
|
||||||
import com.cool.store.vo.PartnerUserInfoVO;
|
import com.cool.store.vo.PartnerUserInfoVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,6 +50,8 @@ import java.util.*;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class LinePayServiceImpl implements LinePayService {
|
public class LinePayServiceImpl implements LinePayService {
|
||||||
|
|
||||||
|
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||||
|
private String eid;
|
||||||
@Resource
|
@Resource
|
||||||
private LinePayDAO linePayDAO;
|
private LinePayDAO linePayDAO;
|
||||||
|
|
||||||
@@ -62,7 +69,8 @@ public class LinePayServiceImpl implements LinePayService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ShopInfoMapper shopInfoMapper;
|
ShopInfoMapper shopInfoMapper;
|
||||||
|
@Autowired
|
||||||
|
private RedisUtilPool redisUtilPool;
|
||||||
@Override
|
@Override
|
||||||
public LinePayVO getLinePayInfo(Long lineId, Integer businessType, Long shopId) {
|
public LinePayVO getLinePayInfo(Long lineId, Integer businessType, Long shopId) {
|
||||||
LinePayVO result = null;
|
LinePayVO result = null;
|
||||||
@@ -78,16 +86,22 @@ public class LinePayServiceImpl implements LinePayService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Integer updateLinePayInfo(Long lineId, Integer businessType, AmountDTO amount, String userId) {
|
public Boolean setAmount(Long lineId, String amount) {
|
||||||
LinePayDO linePayDO = linePayDAO.getByLineIdAndPayTypeAndShopId(lineId, businessType, null);
|
String key = MessageFormat.format(CommonConstants.AMOUNT_KEY, eid, lineId);
|
||||||
if (linePayDO != null) {
|
redisUtilPool.setString(key, amount);
|
||||||
linePayDO.setAmount(amount.getAmount());
|
return Boolean.TRUE;
|
||||||
linePayDO.setUpdateTime(new Date());
|
|
||||||
linePayDO.setUpdateUserId(userId);
|
|
||||||
return linePayDAO.updateLinePay(linePayDO);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAmount(Long lineId) {
|
||||||
|
String key = MessageFormat.format(CommonConstants.AMOUNT_KEY, eid, lineId);
|
||||||
|
String getAmount = redisUtilPool.getString(key);
|
||||||
|
if (StringUtils.isNotBlank(getAmount)) {
|
||||||
|
return getAmount;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean skipPay(Long lineId, LoginUserInfo user) {
|
public Boolean skipPay(Long lineId, LoginUserInfo user) {
|
||||||
log.info("skipPay lineId:{},操作人:{}",lineId,user.getName());
|
log.info("skipPay lineId:{},操作人:{}",lineId,user.getName());
|
||||||
|
|||||||
@@ -32,11 +32,16 @@ public class PCLinePayController {
|
|||||||
@Resource
|
@Resource
|
||||||
private LinePayService linePayService;
|
private LinePayService linePayService;
|
||||||
|
|
||||||
@ApiOperation("修改意向金缴费金额")
|
@ApiOperation("保存意向金额")
|
||||||
@PostMapping("/updateLinePayInfo")
|
@PostMapping("/setAmount")
|
||||||
public ResponseResult<Integer> updateLinePayInfo(@RequestParam("lineId")Long lineId,@RequestBody AmountDTO amount) {
|
public ResponseResult<Boolean> setAmount(@RequestParam("lineId")Long lineId,@RequestBody AmountDTO amount) {
|
||||||
return ResponseResult.success(linePayService.updateLinePayInfo(lineId, PayBusinessTypeEnum.INTENT_MONEY.getCode(),amount, CurrentUserHolder.getUserId()));
|
return ResponseResult.success(linePayService.setAmount( lineId,amount.getAmount().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询意向金额")
|
||||||
|
@GetMapping("/getAmount")
|
||||||
|
public ResponseResult<String> getAmount(@RequestParam("lineId") Long lineId) {
|
||||||
|
return ResponseResult.success(linePayService.getAmount(lineId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import javax.annotation.Resource;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/mini/linePay")
|
@RequestMapping("/mini/linePay")
|
||||||
@Api(tags = "缴纳意向金")
|
@Api(tags = "mini缴纳意向金")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class LinePayController {
|
public class LinePayController {
|
||||||
|
|
||||||
@@ -48,11 +48,10 @@ public class LinePayController {
|
|||||||
return ResponseResult.success(linePayService.submitPayInfo(request, partnerUser));
|
return ResponseResult.success(linePayService.submitPayInfo(request, partnerUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改意向金缴费金额")
|
@ApiOperation("查询意向金额")
|
||||||
@PostMapping("/updateLinePayInfo")
|
@GetMapping("/getAmount")
|
||||||
public ResponseResult<Integer> updateLinePayInfo(@RequestParam("lineId")Long lineId,@RequestBody AmountDTO amount) {
|
public ResponseResult<String> getAmount(@RequestParam("lineId") Long lineId) {
|
||||||
return ResponseResult.success(linePayService.updateLinePayInfo(lineId, PayBusinessTypeEnum.INTENT_MONEY.getCode(),amount, CurrentUserHolder.getUserId()));
|
return ResponseResult.success(linePayService.getAmount(lineId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user