修改区域公司

dev-discount
袁野 2 years ago
parent 6039958843
commit 497a7a30af
  1. 34
      hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java
  2. 23
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  3. 2
      hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java
  4. 56
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  5. 2
      hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java
  6. 2
      hai-cweb/src/main/resources/dev/logback.xml
  7. 2
      hai-schedule/src/main/resources/prod/logback.xml
  8. 2
      hai-service/src/main/java/com/hai/common/utils/WxUtils.java
  9. 10
      hai-service/src/main/java/com/hai/entity/ApiStarbucksProducts.java
  10. 2
      hai-service/src/main/java/com/hai/entity/HighApprove.java
  11. 3
      hai-service/src/main/java/com/hai/enum_type/ApproveType.java
  12. 16
      hai-service/src/main/java/com/hai/service/BsIntegralRebateService.java
  13. 17
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  14. 23
      hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java
  15. 2
      hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java
  16. 112
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  17. 13
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  18. 1
      v1/src/main/java/com/v1/config/AuthConfig.java
  19. 17
      v1/src/main/java/com/v1/config/SysConfig.java
  20. 92
      v1/src/main/java/com/v1/controller/WxMsgController.java
  21. 2
      v1/src/main/resources/dev/config.properties
  22. 3
      v1/src/main/resources/dev/logback.xml

@ -8,6 +8,7 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighApprove;
import com.hai.enum_type.ApproveType;
@ -145,4 +146,37 @@ public class HighApproveController {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/addApprove",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "添加审批")
public ResponseData addApprove(@RequestBody JSONObject object ,HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
HighApprove approve = new HighApprove();
approve.setObjectId(99L);
approve.setObjectName("卡券分发审批");
approve.setApproveSerialNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss"));
approve.setStatus(1);
approve.setCreateTime(new Date());
approve.setUpdateTime(new Date());
approve.setSubmitOperatorId(userInfoModel.getSecUser().getId());
approve.setSubmitOperatorName(userInfoModel.getSecUser().getUserName());
approve.setObjectType(object.getInteger("objectType"));
approve.setApproveObject(object.getJSONObject("approveObject").toJSONString());
highApproveService.insertApprove(approve);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighCouponController -> approveProcessed() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -768,4 +768,27 @@ public class HighCouponController {
}
}
@RequestMapping(value="/getCouponListByAll",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询所有卡卷列表")
public ResponseData getCouponListByAll(HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("HighCouponController -> getCouponList() error!","权限不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
Map<String, Object> map = new HashMap<>(3);
map.put("companyId", userInfoModel.getBsCompany().getId());
map.put("status", 2);
return ResponseMsgUtil.success(highCouponService.getCouponListByAll(map));
} catch (Exception e) {
log.error("HighCouponController -> getCouponList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -144,6 +144,7 @@ public class OutRechargeOrderController {
@RequestParam(name = "payType", required = false) Integer payType,
@RequestParam(name = "payTimeS", required = false) Long payTimeS,
@RequestParam(name = "payTimeE", required = false) Long payTimeE,
@RequestParam(name = "whetherTimeOut", required = false) Boolean whetherTimeOut,
@RequestParam(name = "createTimeS", required = false) Long createTimeS,
@RequestParam(name = "createTimeE", required = false) Long createTimeE,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@ -169,6 +170,7 @@ public class OutRechargeOrderController {
map.put("rechargeStatus", rechargeStatus);
map.put("payStatus", payStatus);
map.put("orderNo", orderNo);
map.put("whetherTimeOut", whetherTimeOut);
map.put("operatorType", operatorType);
map.put("laborUnionCard", laborUnionCard);
map.put("rechargeContent", rechargeContent);

@ -8,14 +8,9 @@ import com.hai.common.exception.SysCode;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.entity.ApiCity;
import com.hai.entity.BsCompany;
import com.hai.entity.SecConfig;
import com.hai.entity.SecRegion;
import com.hai.entity.*;
import com.hai.model.ResponseData;
import com.hai.service.BsCompanyService;
import com.hai.service.CommonService;
import com.hai.service.SecConfigService;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.util.crypto.SHA1;
@ -25,6 +20,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -47,6 +43,11 @@ public class CommonController {
@Resource
private BsCompanyService bsCompanyService;
@Resource
private HighOrderService highOrderService;
@Resource
private BsIntegralRebateService bsIntegralRebateService;
@RequestMapping(value="/getDredgeProvince",method= RequestMethod.GET)
@ResponseBody
@ -231,7 +232,7 @@ public class CommonController {
}
}
@RequestMapping(value = "/getScanCodePageHtmlSign", method = RequestMethod.POST)
@RequestMapping(value = "/ getScanCodePageHtmlSign", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取扫码页面签名")
public ResponseData getScanCodePageHtmlSign(@RequestBody JSONObject body) {
@ -321,7 +322,7 @@ public class CommonController {
@RequestMapping(value = "/findCompanyByCityName", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取定位信息")
public ResponseData findByLatAndLng(
public ResponseData findCompanyByCityName(
@RequestParam(name = "cityName", required = true) String cityName
) {
try {
@ -356,4 +357,41 @@ public class CommonController {
}
}
@RequestMapping(value = "/getRebateIntegral", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询可获取返利积分")
public ResponseData getRebateIntegral(@RequestBody JSONObject object) {
try {
if (object.getInteger("type") == null ||
object.getLong("companyId") == null ||
object.getLong("productId") == null ||
object.getBigDecimal("price") == null
) {
log.error("CommonController -> getRebateIntegral() error!","请求参数校验失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
// 查询订单来源
Map<String, Object> map = new HashMap<>();
map.put("type" , object.getInteger("type"));
map.put("productId" , object.getLong("productId"));
map.put("companyId" , object.getLong("companyId"));
BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map);
if (bsIntegralRebate == null) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无积分返利活动");
}
BigDecimal integralNum = object.getBigDecimal("price").multiply(bsIntegralRebate.getPercentage()).setScale( 0, BigDecimal.ROUND_HALF_UP );
return ResponseMsgUtil.success(integralNum);
} catch (Exception e) {
log.error("HighOrderController --> unionStagingPay() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -129,6 +129,7 @@ public class HighThirdPartyController {
}
apiStarbucksProducts.setSalesVentiPrice(salesVentiPrice);
apiStarbucksProducts.setSalesTallPrice(salesTallPrice);
apiStarbucksProducts.setCount(0);
apiStarbucksProducts.setSalesGrandePrice(salesGrandePrice);
starbucksProductsList.add(apiStarbucksProducts);
}
@ -241,6 +242,7 @@ public class HighThirdPartyController {
salePriceF = productsObject.getBigDecimal("originalPrice");
}
productsObject.put("salePrice", salePriceF);
productsObject.put("count" , 0);
if (productsObject.getJSONArray("specGroups") != null) {
for (Object specGroups : productsObject.getJSONArray("specGroups")) {

@ -60,7 +60,7 @@
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
<logger name="com.hai" level="DEBUG">
<logger name="com.hai" level="INFO">
<appender-ref ref="baselog" />
</logger>
<logger name="com.hai.dao" level="DEBUG">

@ -60,7 +60,7 @@
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
<logger name="com.hai" level="DEBUG">
<logger name="com.hai" level="INFO">
<appender-ref ref="baselog" />
</logger>
<logger name="com.hai.dao" level="DEBUG">

@ -488,8 +488,10 @@ public class WxUtils {
continue;
}
if (data.get(k) != null) // 参数值为空,则不参与签名
{
sb.append(k).append("=").append(data.get(k)).append("&");
}
}
sb.append("apiKey=").append(key);
if (WXPayConstants.SignType.MD5.equals(signType)) {
return MD5(sb.toString() , true);

@ -129,6 +129,8 @@ public class ApiStarbucksProducts implements Serializable {
*/
private Integer status;
private Integer count;
/**
* ext_1
*/
@ -144,6 +146,14 @@ public class ApiStarbucksProducts implements Serializable {
*/
private String ext3;
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
private static final long serialVersionUID = 1L;
public Long getId() {

@ -19,7 +19,7 @@ public class HighApprove implements Serializable {
private Long id;
/**
* 审批对象 1:卡券上架审批 2:卡卷价格审批
* 审批对象 1:卡券上架审批 2:卡卷价格审批 3:卡券分发审批
*/
private Integer objectType;

@ -7,7 +7,8 @@ package com.hai.enum_type;
*/
public enum ApproveType {
UP_SHELF_APPROVE(1, "卡卷上架审批"),
COUPON_PRICE_APPROVE(2, "卡卷价格审批")
COUPON_PRICE_APPROVE(2, "卡卷价格审批"),
COUPON_DISTRIBUTE_APPROVE(3, "卡卷分发审批"),
;
private Integer type;

@ -77,8 +77,24 @@ public interface BsIntegralRebateService {
**/
void deleteIntegralRebate(Long id);
/**
* @Author Sum1Dream
* @Name integralRebate
* @Description // 订单积分返利
* @Date 11:32 2022/9/1
* @Param [object]
* @Return void
*/
void integralRebate(JSONObject object);
/**
* @Author Sum1Dream
* @Name integralRechargeRebate
* @Description // 话费订单返利
* @Date 11:33 2022/9/1
* @Param [object]
* @Return void
*/
void integralRechargeRebate(JSONObject object);
}

@ -73,6 +73,16 @@ public interface HighCouponService {
**/
void priceApproveResult(HighApprove highApprove);
/**
* @Author Sum1Dream
* @Name distributeApprove
* @Description // 卡券分发审批
* @Date 16:57 2022/8/31
* @Param [highApprove]
* @Return void
*/
void distributeApprove(HighApprove highApprove);
/**
* @Author 胡锐
* @Description 根据id查询卡卷基本信息赠送信息
@ -105,6 +115,13 @@ public interface HighCouponService {
**/
List<HighCoupon> getCouponList(Map<String, Object> map);
/**
* @Author 胡锐
* @Description 获取卡卷集合
* @Date 2021/3/15 23:12
**/
List<HighCoupon> getCouponListByAll(Map<String, Object> map);
/**
* @Author 胡锐
* @Description 获取数量

@ -1,15 +1,16 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.dao.HighApproveMapper;
import com.hai.entity.HighApprove;
import com.hai.entity.HighApproveExample;
import com.hai.entity.HighCoupon;
import com.hai.entity.*;
import com.hai.enum_type.ApproveType;
import com.hai.model.HighCouponModel;
import com.hai.service.HighAgentService;
import com.hai.service.HighApproveService;
import com.hai.service.HighCouponAgentService;
import com.hai.service.HighCouponService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
@ -36,8 +37,9 @@ public class HighApproveServiceImpl implements HighApproveService {
@Resource
private HighCouponService highCouponService;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
@Transactional(propagation= Propagation.REQUIRES_NEW ,rollbackFor = Exception.class)
public void insertApprove(HighApprove highApprove) {
// 卡卷上架审批
@ -49,6 +51,11 @@ public class HighApproveServiceImpl implements HighApproveService {
if (Objects.equals(highApprove.getObjectType(), ApproveType.COUPON_PRICE_APPROVE.getType())) {
// 暂时不需要调用接口
}
// 卡卷分发审批
if (Objects.equals(highApprove.getObjectType(), ApproveType.COUPON_DISTRIBUTE_APPROVE.getType())) {
// 暂时不需要调用接口
}
highApproveMapper.insert(highApprove);
}
@ -64,14 +71,18 @@ public class HighApproveServiceImpl implements HighApproveService {
@Override
public void approveProcessed(HighApprove highApprove) {
if (highApprove.getObjectType() == ApproveType.UP_SHELF_APPROVE.getType()) {
if (highApprove.getObjectType().equals(ApproveType.UP_SHELF_APPROVE.getType())) {
highCouponService.upShelfApproveResult(highApprove);
}
if (highApprove.getObjectType() == ApproveType.COUPON_PRICE_APPROVE.getType()) {
if (highApprove.getObjectType().equals(ApproveType.COUPON_PRICE_APPROVE.getType())) {
highCouponService.priceApproveResult(highApprove);
}
if (highApprove.getObjectType().equals(ApproveType.COUPON_DISTRIBUTE_APPROVE.getType())) {
highCouponService.distributeApprove(highApprove);
}
updateApprove(highApprove);
}

@ -71,7 +71,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService {
private HighCouponCodeOtherService couponCodeOtherService;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
@Transactional(propagation= Propagation.REQUIRES_NEW , rollbackFor = Exception.class)
public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) {
if (highCouponAgentRel.getId() != null) {
highCouponAgentRelMapper.updateByPrimaryKey(highCouponAgentRel);

@ -1,6 +1,7 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
@ -33,6 +34,9 @@ public class HighCouponServiceImpl implements HighCouponService {
@Resource
private HighCouponMapper highCouponMapper;
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponHandselService highCouponHandselService;
@ -51,6 +55,13 @@ public class HighCouponServiceImpl implements HighCouponService {
@Resource
private HighApproveService highApproveService;
@Resource
private HighAgentService highAgentService;
@Resource
private HighCouponAgentService highCouponAgentService;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertCoupon(HighCoupon highCouponModel) {
@ -279,6 +290,53 @@ public class HighCouponServiceImpl implements HighCouponService {
highGoodsPriceReferService.updatePriceRefer(highGoodsPriceRefer);
}
@Override
public void distributeApprove(HighApprove highApprove) {
JSONObject object = JSONObject.parseObject(highApprove.getApproveObject());
if (highApprove.getStatus() == 3) {
// 查询卡券详情
HighCoupon coupon = highCouponService.getCouponById(object.getLong("couponId"));
if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
}
// 查询代理商
HighAgent highAgent = highAgentService.findByAgentMsgId(object.getLong("agentId"));
if (highAgent == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_AGENT, "");
}
// 校验是否分配过
HighCouponAgentRel couponAgent = highCouponAgentService.getRelByCouponAgent(object.getLong("couponId"), object.getLong("agentId"), object.getInteger("type"));
if (couponAgent != null) {
couponAgent.setStockCount(couponAgent.getStockCount() + object.getInteger("stockCount"));
couponAgent.setOperatorId(highApprove.getSubmitOperatorId());
couponAgent.setOperatorName(highApprove.getSubmitOperatorName());
highCouponAgentService.assignCouponAgent(couponAgent,object.getInteger("stockCount"));
} else {
HighCouponAgentRel highCouponAgentRel = new HighCouponAgentRel();
highCouponAgentRel.setCouponName(coupon.getCouponName());
highCouponAgentRel.setSalesPrice(coupon.getSalesPrice());
// 状态 0:删除 1:正常
highCouponAgentRel.setStatus(1);
highCouponAgentRel.setSalesCount(0);
highCouponAgentRel.setType(object.getInteger("type"));
highCouponAgentRel.setCouponId(object.getLong("couponId"));
highCouponAgentRel.setAgentId(object.getLong("agentId"));
highCouponAgentRel.setStockCount(object.getInteger("stockCount"));
highCouponAgentRel.setCreateTime(new Date());
highCouponAgentRel.setOperatorId(highApprove.getSubmitOperatorId());
highCouponAgentRel.setOperatorName(highApprove.getSubmitOperatorName());
highCouponAgentService.assignCouponAgent(highCouponAgentRel,highCouponAgentRel.getStockCount());
}
}
}
@Override
public HighCoupon getCouponById(Long id) {
HighCoupon highCoupon = highCouponMapper.selectByPrimaryKey(id);
@ -390,6 +448,60 @@ public class HighCouponServiceImpl implements HighCouponService {
return coupons;
}
@Override
public List<HighCoupon> getCouponListByAll(Map<String, Object> map) {
HighCouponExample example = new HighCouponExample();
HighCouponExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId"));
}
if (MapUtils.getLong(map, "merchantId") != null) {
criteria.andMerchantIdEqualTo(MapUtils.getLong(map, "merchantId"));
}
if (StringUtils.isNotBlank(MapUtils.getString(map, "couponName"))) {
criteria.andCouponNameLike("%" + MapUtils.getString(map, "couponName") + "%");
}
if (MapUtils.getInteger(map, "couponType") != null) {
criteria.andCouponTypeEqualTo(MapUtils.getInteger(map, "couponType"));
}
if (MapUtils.getInteger(map, "displayArea") != null) {
criteria.andDisplayAreaEqualTo(MapUtils.getInteger(map, "displayArea"));
}
if (MapUtils.getInteger(map, "displayArea") != null) {
criteria.andDisplayAreaEqualTo(MapUtils.getInteger(map, "displayArea"));
}
if (MapUtils.getInteger(map, "brandId") != null) {
criteria.andBrandIdEqualTo(MapUtils.getInteger(map, "brandId"));
}
if (MapUtils.getInteger(map, "goodsTypeId") != null) {
criteria.andGoodsTypeIdEqualTo(MapUtils.getInteger(map, "goodsTypeId"));
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
if (MapUtils.getInteger(map, "couponSource") != null) {
criteria.andCouponSourceEqualTo(MapUtils.getInteger(map, "status"));
}
if (MapUtils.getInteger(map, "notCouponSource") != null) {
criteria.andCouponSourceNotEqualTo(MapUtils.getInteger(map, "notCouponSource"));
}
example.setOrderByClause("create_time");
return highCouponMapper.selectByExample(example);
}
@Override
public Long getCouponByCouponName(Long companyId,String couponName) {
HighCouponExample example = new HighCouponExample();

@ -165,6 +165,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
DateUtil.format(MapUtils.getString(map, "createTimeS"), "yyyy-MM-dd HH:mm:ss"),
DateUtil.format(MapUtils.getString(map, "createTimeE"), "yyyy-MM-dd HH:mm:ss"));
}
if (MapUtils.getBoolean(map , "whetherTimeOut")) {
// 获取当前时间
Date date= new Date();
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
// 把日期往前减少三天,整数 往后推,负数往前移动
calendar.add(Calendar.DATE, -3);
// 这个时间就是日期往后推一天的结果
date = calendar.getTime();
criteria.andCreateTimedLessThan(date);
}
example.setOrderByClause("create_timed desc");
return outRechargeOrderMapper.selectByExample(example);

@ -95,6 +95,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/thirdParty/*")
.excludePathPatterns("/selfOilStation/*")
.excludePathPatterns("/order/*")
.excludePathPatterns("/wxMsg/*")
;
}

@ -9,5 +9,22 @@ import org.springframework.stereotype.Component;
@PropertySource("classpath:/config.properties")
public class SysConfig {
private String wxH5AppId;
private String wxH5AppSecret;
public String getWxH5AppId() {
return wxH5AppId;
}
public void setWxH5AppId(String wxH5AppId) {
this.wxH5AppId = wxH5AppId;
}
public String getWxH5AppSecret() {
return wxH5AppSecret;
}
public void setWxH5AppSecret(String wxH5AppSecret) {
this.wxH5AppSecret = wxH5AppSecret;
}
}

@ -0,0 +1,92 @@
package com.v1.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.model.ResponseData;
import com.v1.config.SysConst;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.chanjar.weixin.common.util.crypto.SHA1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* @author sum1dream
*/
@Controller
@RequestMapping(value = "/wxMsg")
@Api(value = "自建站接口")
public class WxMsgController {
private static Logger log = LoggerFactory.getLogger(ThirdPartyController.class);
@RequestMapping(value = "/verifyWxToken", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "验证servlet")
public String verifyWxToken(HttpServletRequest request) {
try {
log.info("进入验证servlet!!!!!");
log.info(String.valueOf(request));
String msgSignature = request.getParameter("signature");
String msgTimestamp = request.getParameter("timestamp");
String msgNonce = request.getParameter("nonce");
String echoStr = request.getParameter("echoStr");
Map<String, Object> params = new HashMap<>();
params.put("timestamp", msgTimestamp);
params.put("nonce", msgNonce);
String signatureStr = WxUtils.generateSignature(params);
String sign = SHA1.gen(signatureStr);
if (msgSignature.equals(sign)) {
log.info("验证通过!!!!!");
return echoStr;
}
log.info("验证失败!!!!!");
return null;
} catch (Exception e) {
return null;
}
}
@RequestMapping(value = "/getWxToken", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取微信token")
public ResponseData getWxToken() {
try {
Map<String, Object> params = new HashMap<>();
params.put("appid", SysConst.getSysConfig().getWxH5AppId());
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params);
if (accessTokenObject == null) {
log.error("getH5UserInfo error!", "获取微信access_token失败" );
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信access_token失败");
}
return ResponseMsgUtil.success(accessTokenObject);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,2 @@
wxH5AppId=wxb05f4cb44994a960
wxH5AppSecret=68b540ebce7a4020420f4e5997b1531b

@ -63,6 +63,9 @@
<logger name="com.hai" level="DEBUG">
<appender-ref ref="baselog" />
</logger>
<logger name="com.hai" level="INFO">
<appender-ref ref="baselog" />
</logger>
<logger name="com.hai.dao" level="DEBUG">
<appender-ref ref="daolog" />
</logger>

Loading…
Cancel
Save