cpupon-dev
袁野 2 months ago
parent 85e911a4cb
commit 2206ea32c1
  1. 1
      bweb/src/main/java/com/bweb/config/AuthConfig.java
  2. 39
      bweb/src/main/java/com/bweb/controller/TestController.java
  3. 68
      bweb/src/main/java/com/bweb/controller/api/ApiMerController.java
  4. 4
      openapi/src/main/resources/prod/application.yml
  5. 16
      order/src/main/java/com/order/controller/notify/MeiTuanController.java
  6. 68
      service/src/main/java/com/hfkj/api/ApiMerService.java
  7. 68
      service/src/main/java/com/hfkj/api/impl/ApiMerServiceImpl.java
  8. 1
      service/src/main/java/com/hfkj/service/user/BsUserService.java
  9. 28
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java
  10. 1
      service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java
  11. 1
      service/src/main/java/com/hfkj/sysenum/UserLoginType.java
  12. 105
      user/src/main/java/com/user/controller/BsUserController.java

@ -89,6 +89,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/fileUpload/*") .excludePathPatterns("/fileUpload/*")
.excludePathPatterns("/common/*") .excludePathPatterns("/common/*")
.excludePathPatterns("/test/*") .excludePathPatterns("/test/*")
.excludePathPatterns("/apiMer/*")
.excludePathPatterns("/secMenu/queryMenuList") .excludePathPatterns("/secMenu/queryMenuList")
.excludePathPatterns("/user/phgDataUser") .excludePathPatterns("/user/phgDataUser")
.excludePathPatterns("/user/phgDataUserDetail") .excludePathPatterns("/user/phgDataUserDetail")

@ -450,6 +450,24 @@ public class TestController {
} }
} }
@RequestMapping(value="/queryHltBalance",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询工会卡余额")
public ResponseData queryHltBalance(@RequestParam(value = "cardNo", required = false) String cardNo) {
try {
JSONObject cardInfo = HuiLianTongUnionCardService.queryBalance(cardNo);
if (StringUtils.isBlank(cardInfo.getString("data"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败");
}
return ResponseMsgUtil.success(HuiLianTongUnionCardService.resolveResponse(cardInfo.getString("data")));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getGoodsUpdate",method = RequestMethod.GET) @RequestMapping(value="/getGoodsUpdate",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "更新商品") @ApiOperation(value = "更新商品")
@ -478,4 +496,25 @@ public class TestController {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@RequestMapping(value="/phgSignLogin",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "加密登陆")
public ResponseData phgSignLogin() {
try {
Map<String , Object> map = new HashMap<>();
map.put("appid" , "20241266600");
map.put("phone" , "18390580471");
map.put("sign" , SignatureUtil.createSign(map , "BCB83776BDA7F609FBE99BBB8AC33840"));
map.put("platform" , "HIGH");
map.put("type" , "HIGH_SIGN");
return ResponseMsgUtil.success( HttpsUtils.doPost("http://localhost:9704/user/client/phgSignLogin" , map , new HashMap<>()));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -0,0 +1,68 @@
package com.bweb.controller.api;
import com.hfkj.api.ApiMerService;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.IDGenerator;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.common.utils.WxUtils;
import com.hfkj.entity.ApiMer;
import com.hfkj.model.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
@Controller
@RequestMapping(value = "/apiMer")
@Api(value = "api商户")
public class ApiMerController {
Logger log = LoggerFactory.getLogger(ApiMerController.class);
@Resource
private ApiMerService apiMerService;
@RequestMapping(value="/insertMerchant",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加商户")
public ResponseData insertMer(@RequestBody ApiMer apiMer) {
try {
if (StringUtils.isBlank(apiMer.getMerName())
|| StringUtils.isBlank(apiMer.getContact())
|| StringUtils.isBlank(apiMer.getContactPhone())
) {
log.error("ApiMerchantsController -> insertMerchant() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
apiMer.setCreateTime(new Date());
apiMer.setUpdateTime(new Date());
apiMer.setStatus(1);
apiMer.setAppId(DateUtil.date2String(new Date(), "yyyyMM") + IDGenerator.nextId(5));
apiMer.setAppSecret(WxUtils.MD5(apiMer.getAppId() , true));
apiMerService.create(apiMer);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("ApiMerchantsController -> insertMerchant() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,7 +1,7 @@
server: server:
port: 9301 port: 9505
servlet: servlet:
context-path: /crest context-path: /openapi
#配置是否为debug模式,debug模式下,不开启权限校验 #配置是否为debug模式,debug模式下,不开启权限校验
debug: false debug: false

@ -5,6 +5,7 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.OrderUtil; import com.hfkj.common.utils.OrderUtil;
import com.hfkj.common.utils.SignatureUtil;
import com.hfkj.config.CommonSysConst; import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsOrderMeituan; import com.hfkj.entity.BsOrderMeituan;
import com.hfkj.entity.BsOrderRefund; import com.hfkj.entity.BsOrderRefund;
@ -103,11 +104,22 @@ public class MeiTuanController {
JSONObject staffInfo = jsonObject.getJSONObject("staffInfo"); JSONObject staffInfo = jsonObject.getJSONObject("staffInfo");
// 请求加密
Map<String , Object> map = new HashMap<>();
map.put("appid" , "20241266600");
map.put("phone" , staffInfo.getString("staffPhone"));
String sign = SignatureUtil.createSign(map , "BCB83776BDA7F609FBE99BBB8AC33840");
object.put("thirdTradeNo", thirdTradeNo); object.put("thirdTradeNo", thirdTradeNo);
object.put("thirdPayUrl", "https://phg.dctpay.com/cweb/#/pages/meiTuanPay/index?tradeNo=" + jsonObject.getString("tradeNo") + object.put("thirdPayUrl", "https://phg.dctpay.com/cweb/#/pages/meiTuanPay/index?tradeNo=" + jsonObject.getString("tradeNo") +
"&tradeAmount=" + jsonObject.getString("tradeAmount") + "&tradeAmount=" + jsonObject.getString("tradeAmount") +
"&outSidePhone=" + staffInfo.getString("staffPhone") "&outSideAppid=" + map.get("appid") +
); "&outSideSign=" + sign +
"&outSidePhone=" + staffInfo.getString("staffPhone") +
"&outsidePlatform=" + "WXAPPLETS" +
"&outSideType=" + "SIGN"
);
log.info("美团下单-参数: {}", object); log.info("美团下单-参数: {}", object);
data.put("status", 0); data.put("status", 0);
data.put("msg", "成功"); data.put("msg", "成功");

@ -0,0 +1,68 @@
package com.hfkj.api;
import com.hfkj.entity.ApiMer;
import java.util.List;
public interface ApiMerService {
/**
* @MethodName create
* @Description: 创建api商户
* @param apiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
void create(ApiMer apiMer);
/**
* @MethodName update
* @Description: /**
* @Description: 更新api商户
* @param apiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
void update(ApiMer apiMer);
/**
* @MethodName delete
* @Description: 删除api商户
* @param id
* @param fullDelete
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
void delete(Long id , Boolean fullDelete);
/**
* @MethodName queryDetail
* @Description: 查询api商户详情
* @param id
* @return: com.hfkj.entity.ApiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
ApiMer queryDetail(Long id);
/**
* @MethodName queryDetail
* @Description: 根据appId查询商户
* @param appId
* @return: com.hfkj.entity.ApiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:20
*/
ApiMer queryDetail(String appId);
/**
* @MethodName queryList
* @Description: 查询api商户列表
* @param apiMer
* @return: java.util.List<com.hfkj.entity.ApiMer>
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:20
*/
List<ApiMer> queryList(ApiMer apiMer);
}

@ -0,0 +1,68 @@
package com.hfkj.api.impl;
import com.hfkj.api.ApiMerService;
import com.hfkj.dao.ApiMerMapper;
import com.hfkj.entity.ApiMer;
import com.hfkj.entity.ApiMerExample;
import com.hfkj.entity.BsOrderGoods;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@Service("apiMerService")
public class ApiMerServiceImpl implements ApiMerService {
@Resource
private ApiMerMapper apiMerMapper;
@Override
public void create(ApiMer apiMer) {
apiMerMapper.insert(apiMer);
}
@Override
public void update(ApiMer apiMer) {
apiMerMapper.updateByPrimaryKey(apiMer);
}
@Override
public void delete(Long id, Boolean fullDelete) {
if (fullDelete) {
apiMerMapper.deleteByPrimaryKey(id);
} else {
ApiMer apiMer = queryDetail(id);
apiMer.setStatus(0);
apiMer.setUpdateTime(new Date());
update(apiMer);
}
}
@Override
public ApiMer queryDetail(Long id) {
return apiMerMapper.selectByPrimaryKey(id);
}
@Override
public ApiMer queryDetail(String appId) {
ApiMerExample example = new ApiMerExample();
ApiMerExample.Criteria criteria = example.createCriteria();
criteria.andAppIdEqualTo(appId).andStatusEqualTo(1);
List<ApiMer> list = apiMerMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public List<ApiMer> queryList(ApiMer apiMer) {
return Collections.emptyList();
}
}

@ -113,6 +113,7 @@ public interface BsUserService {
*/ */
SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String outsideOpenid, Map<String, Object> other) throws Exception; SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String outsideOpenid, Map<String, Object> other) throws Exception;
SessionObject signLogin(UserLoginPlatform platform, UserLoginType loginType, String phone) throws Exception;
/** /**
* 退出登录 * 退出登录
* @param token * @param token

@ -30,6 +30,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -238,6 +239,33 @@ public class BsUserServiceImpl implements BsUserService {
return sessionObject; return sessionObject;
} }
@Override
public SessionObject signLogin(UserLoginPlatform platform, UserLoginType loginType, String phone) throws Exception {
// 查询用户
BsUser user = getUser(phone);
if (user == null) {
user = register(phone, null , new HashMap<>());
}
// 缓存
UserSessionObject session = new UserSessionObject();
session.setUser(user);
// 查询汇联通工会卡
List<BsUserCard> hltCardList = userCardService.getCardList(user.getId(), UserCardTypeEnum.type1);
if (hltCardList.isEmpty()) {
session.setHltCardBind(false);
} else {
session.setHltCardBind(true);
session.setHltCard(hltCardList.get(0));
}
SessionObject sessionObject = new SessionObject(token(user), session);
userCenter.save(sessionObject);
// 异步记录登录信息
userLoginLogService.asyncCreateLog(platform, loginType, user, (HttpServletRequest) RequestContextHolder.getRequestAttributes().resolveReference(RequestAttributes.REFERENCE_REQUEST));
return sessionObject;
}
@Override @Override
public void loginOut(String token) { public void loginOut(String token) {
userCenter.remove(token); userCenter.remove(token);

@ -13,6 +13,7 @@ public enum UserLoginPlatform {
WXAPPLETS("WXAPPLETS", "普汇GO"), WXAPPLETS("WXAPPLETS", "普汇GO"),
VFAMILY("VFAMILY", "V家园"), VFAMILY("VFAMILY", "V家园"),
GZGOV("GZGOV", "省自机关"), GZGOV("GZGOV", "省自机关"),
HIGH("HIGH", "嗨加油"),
; ;
private String code; private String code;

@ -16,6 +16,7 @@ public enum UserLoginType {
WECHAT_MP_OPENID("WECHAT_MP_OPENID", "微信公众号openId"), WECHAT_MP_OPENID("WECHAT_MP_OPENID", "微信公众号openId"),
V_FAMILY_OPENID("V_FAMILY_OPENID", "V家园openId"), V_FAMILY_OPENID("V_FAMILY_OPENID", "V家园openId"),
GZ_GOV_OPENID("GZ_GOV_OPENID", "省自机关openId"), GZ_GOV_OPENID("GZ_GOV_OPENID", "省自机关openId"),
SIGN("SIGN", "加密登陆"),
; ;
private String code; private String code;

@ -3,12 +3,15 @@ package com.user.controller;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hfkj.api.ApiMerService;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter; import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.*; import com.hfkj.common.utils.*;
import com.hfkj.config.CommonSysConst;
import com.hfkj.config.WxMaConfig; import com.hfkj.config.WxMaConfig;
import com.hfkj.entity.ApiMer;
import com.hfkj.entity.BsUser; import com.hfkj.entity.BsUser;
import com.hfkj.entity.BsUserComplaint; import com.hfkj.entity.BsUserComplaint;
import com.hfkj.model.ResponseData; import com.hfkj.model.ResponseData;
@ -54,6 +57,8 @@ public class BsUserController {
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Resource @Resource
private BsUserComplaintService userComplaintService; private BsUserComplaintService userComplaintService;
@Resource
private ApiMerService apiMerService;
@RequestMapping(value = "/phone", method = RequestMethod.POST) @RequestMapping(value = "/phone", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ -156,48 +161,64 @@ public class BsUserController {
} }
} }
// @RequestMapping(value = "/phoneNotVerify", method = RequestMethod.POST) @RequestMapping(value = "/phgSignLogin", method = RequestMethod.POST)
// @ResponseBody @ResponseBody
// @ApiOperation(value = "H5手机号不校验登陆") @ApiOperation(value = "普惠go加密登陆")
// public ResponseData phoneNotVerify(@RequestBody JSONObject body) { public ResponseData phgSignLogin(@RequestBody JSONObject body) {
// try { try {
// if (body == null if (body == null
// || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("platform"))
// || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("type"))
// || StringUtils.isBlank(body.getString("phone")) || StringUtils.isBlank(body.getString("phone"))
// ) { || StringUtils.isBlank(body.getString("sign"))
// log.error("LoginController --> phone() error!", "请求参数校验失败"); || StringUtils.isBlank(body.getString("appid"))
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); ) {
// } log.error("LoginController --> phone() error!", "请求参数校验失败");
// String phone = body.getString("phone"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// String password = body.getString("password"); }
// String phone = body.getString("phone");
// // 客户端
// UserLoginPlatform platform = UserLoginPlatform.getDataByType(body.getString("platform")); // 客户端
// if (platform == null) { UserLoginPlatform platform = UserLoginPlatform.getDataByType(body.getString( "platform"));
// log.error("LoginController --> phone() error!", "未知客户端"); if (platform == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); log.error("LoginController --> phone() error!", "未知客户端");
// } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端");
// // 校验手机号格式 }
// if (!MemberValidateUtil.validatePhone(phone)) { // 校验手机号格式
// log.error("LoginController --> phone() error!", "请输入正确的手机号"); if (!MemberValidateUtil.validatePhone(phone)) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); log.error("LoginController --> phone() error!", "请输入正确的手机号");
// } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
// // 登录类型 }
// UserLoginType loginType = UserLoginType.getDataByType(body.getString("type")); // 登录类型
// if (loginType == null) { UserLoginType loginType = UserLoginType.getDataByType(body.getString("type"));
// log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type"));
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); if (loginType == null) {
// } log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type"));
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型");
// Map<String, Object> other = new HashMap<>(); }
// return ResponseMsgUtil.success(userService.login(platform, loginType, phone, password, other));
// // 校验签名
// } catch (Exception e) { // 查询api商户信息
// log.error("LoginController --> phone() error!", e); ApiMer apiMer = apiMerService.queryDetail(body.getString("appid"));
// return ResponseMsgUtil.exception(e); if (apiMer == null) {
// } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户不存在");
// } }
Map<String , Object> map = new HashMap<>();
map.put("appid" , body.getString("appid"));
map.put("phone" , body.getString("phone"));
String sign = SignatureUtil.createSign(map , apiMer.getAppSecret());
if (!body.getString("sign").equals(sign)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "签名校验失败!");
}
return ResponseMsgUtil.success(userService.signLogin(platform, loginType, phone));
} catch (Exception e) {
log.error("LoginController --> phone() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/phoneTest", method = RequestMethod.POST) @RequestMapping(value = "/phoneTest", method = RequestMethod.POST)
@ResponseBody @ResponseBody

Loading…
Cancel
Save