意向金 加盟费 合同签约增加修改+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 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 lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -31,7 +32,10 @@ public class WechatRest {
|
||||
|
||||
@Resource
|
||||
private HttpRestTemplateService httpRestTemplateService;
|
||||
|
||||
@Value("${weixin.appId}")
|
||||
private String wxAppId;
|
||||
@Value("${weixin.appSecret}")
|
||||
private String wxAppSecret;
|
||||
/**
|
||||
* 小程序Token 地址
|
||||
*/
|
||||
@@ -97,10 +101,24 @@ public class WechatRest {
|
||||
responseStr = httpRestTemplateService.postForObject(reqUrl, requestMap, String.class);
|
||||
log.info("WechatRest#getUserPhoneNumber, reqUrl:{}, response:{}", reqUrl, 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ public interface LinePayService {
|
||||
|
||||
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
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.cool.store.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.context.LoginUserInfo;
|
||||
import com.cool.store.dao.HyPartnerUserInfoDAO;
|
||||
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.request.LinePaySubmitRequest;
|
||||
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.StringUtils;
|
||||
import com.cool.store.utils.poi.constant.Constants;
|
||||
import com.cool.store.vo.LinePayVO;
|
||||
import com.cool.store.vo.PartnerUserInfoVO;
|
||||
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.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -45,6 +50,8 @@ import java.util.*;
|
||||
@Slf4j
|
||||
public class LinePayServiceImpl implements LinePayService {
|
||||
|
||||
@Value("${mybatis.configuration.variables.enterpriseId}")
|
||||
private String eid;
|
||||
@Resource
|
||||
private LinePayDAO linePayDAO;
|
||||
|
||||
@@ -62,7 +69,8 @@ public class LinePayServiceImpl implements LinePayService {
|
||||
|
||||
@Resource
|
||||
ShopInfoMapper shopInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisUtilPool redisUtilPool;
|
||||
@Override
|
||||
public LinePayVO getLinePayInfo(Long lineId, Integer businessType, Long shopId) {
|
||||
LinePayVO result = null;
|
||||
@@ -78,16 +86,22 @@ public class LinePayServiceImpl implements LinePayService {
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public Integer updateLinePayInfo(Long lineId, Integer businessType, AmountDTO amount, String userId) {
|
||||
LinePayDO linePayDO = linePayDAO.getByLineIdAndPayTypeAndShopId(lineId, businessType, null);
|
||||
if (linePayDO != null) {
|
||||
linePayDO.setAmount(amount.getAmount());
|
||||
linePayDO.setUpdateTime(new Date());
|
||||
linePayDO.setUpdateUserId(userId);
|
||||
return linePayDAO.updateLinePay(linePayDO);
|
||||
}
|
||||
return 0;
|
||||
public Boolean setAmount(Long lineId, String amount) {
|
||||
String key = MessageFormat.format(CommonConstants.AMOUNT_KEY, eid, lineId);
|
||||
redisUtilPool.setString(key, amount);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@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
|
||||
public Boolean skipPay(Long lineId, LoginUserInfo user) {
|
||||
log.info("skipPay lineId:{},操作人:{}",lineId,user.getName());
|
||||
|
||||
@@ -32,11 +32,16 @@ public class PCLinePayController {
|
||||
@Resource
|
||||
private LinePayService linePayService;
|
||||
|
||||
@ApiOperation("修改意向金缴费金额")
|
||||
@PostMapping("/updateLinePayInfo")
|
||||
public ResponseResult<Integer> updateLinePayInfo(@RequestParam("lineId")Long lineId,@RequestBody AmountDTO amount) {
|
||||
return ResponseResult.success(linePayService.updateLinePayInfo(lineId, PayBusinessTypeEnum.INTENT_MONEY.getCode(),amount, CurrentUserHolder.getUserId()));
|
||||
@ApiOperation("保存意向金额")
|
||||
@PostMapping("/setAmount")
|
||||
public ResponseResult<Boolean> setAmount(@RequestParam("lineId")Long lineId,@RequestBody AmountDTO amount) {
|
||||
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
|
||||
@RequestMapping("/mini/linePay")
|
||||
@Api(tags = "缴纳意向金")
|
||||
@Api(tags = "mini缴纳意向金")
|
||||
@Slf4j
|
||||
public class LinePayController {
|
||||
|
||||
@@ -48,11 +48,10 @@ public class LinePayController {
|
||||
return ResponseResult.success(linePayService.submitPayInfo(request, partnerUser));
|
||||
}
|
||||
|
||||
@ApiOperation("修改意向金缴费金额")
|
||||
@PostMapping("/updateLinePayInfo")
|
||||
public ResponseResult<Integer> updateLinePayInfo(@RequestParam("lineId")Long lineId,@RequestBody AmountDTO amount) {
|
||||
return ResponseResult.success(linePayService.updateLinePayInfo(lineId, PayBusinessTypeEnum.INTENT_MONEY.getCode(),amount, CurrentUserHolder.getUserId()));
|
||||
@ApiOperation("查询意向金额")
|
||||
@GetMapping("/getAmount")
|
||||
public ResponseResult<String> getAmount(@RequestParam("lineId") Long lineId) {
|
||||
return ResponseResult.success(linePayService.getAmount(lineId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user