袁野 4 months ago
parent 150b638ce5
commit eceacdabe6
  1. 48
      cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java
  2. 1
      order/src/main/java/com/order/controller/OrderController.java
  3. 32
      order/src/main/java/com/order/controller/OrderPayController.java
  4. 23
      order/src/main/java/com/order/controller/business/BsOrderCinemaController.java
  5. 5
      service/src/main/java/com/hfkj/model/order/OrderModel.java
  6. 20
      service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java
  7. 71
      service/src/main/java/com/hfkj/service/order/BsOrderOutsideService.java
  8. 2
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  9. 5
      service/src/main/java/com/hfkj/service/order/OrderCreateService.java
  10. 15
      service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java
  11. 55
      service/src/main/java/com/hfkj/service/order/impl/BsOrderOutsideServiceImpl.java
  12. 22
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java
  13. 2
      service/src/main/java/com/hfkj/service/user/BsUserLoginLogService.java
  14. 27
      service/src/main/java/com/hfkj/service/user/BsUserService.java
  15. 15
      service/src/main/java/com/hfkj/service/user/impl/BsUserLoginLogServiceImpl.java
  16. 47
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java
  17. 2
      service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java
  18. 2
      service/src/main/java/com/hfkj/sysenum/UserLoginType.java
  19. 44
      user/src/main/java/com/user/controller/BsUserController.java

@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
@ -176,6 +177,25 @@ public class CinemaController {
}
}
@RequestMapping(value="/getByCinemasId",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据影院id查询影院")
public ResponseData getByCinemasId(
@RequestParam(name = "cinemaId", required = true) Integer cinemaId
) {
try {
Map<String, Object> params = new HashMap<>();
params.put("cinemaId", cinemaId);
return ResponseMsgUtil.success(CinemaService.getByCinemasId(params));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/listByCinemaAndFilm",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据影院和影片查询场次")
@ -238,6 +258,17 @@ public class CinemaController {
JSONObject object = CinemaService.pagedQuery(params);
JSONArray jsonArray = object.getJSONArray("data");
BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type3.getCode());
for (Object array: jsonArray) {
JSONObject jsonObject = (JSONObject) array;
BigDecimal salePrice = jsonObject.getBigDecimal("price").add(jsonObject.getBigDecimal("fastModePrice").multiply(productConfig.getDiscount()).divide(new BigDecimal(100) , 2, RoundingMode.HALF_UP));
if (salePrice.compareTo(jsonObject.getBigDecimal("price")) > 0) {
jsonObject.put("salePrice" , salePrice);
} else {
jsonObject.put("salePrice" , jsonObject.getBigDecimal("price"));
}
}
JSONArray newJSONArray = jsonArray.stream().sorted(
// 根据对象中的ID进行升序排序 小到大
@ -272,6 +303,7 @@ public class CinemaController {
JSONObject object = CinemaService.getRealTimeSeatByShowId(params).getJSONObject("data");
JSONArray jsonArray = object.getJSONArray("seats");
JSONArray areaPrices = object.getJSONArray("areaPrices");
BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type3.getCode());
@ -281,7 +313,7 @@ public class CinemaController {
for(Object s : seats) {
JSONObject jsonObject = (JSONObject) s;
if (jsonObject != null) {
BigDecimal salePrice = jsonObject.getBigDecimal("fastDrawModePrice").multiply(productConfig.getDiscount()).divide(new BigDecimal(100) , 2, BigDecimal.ROUND_HALF_UP);
BigDecimal salePrice = jsonObject.getBigDecimal("price").add(jsonObject.getBigDecimal("fastDrawModePrice").multiply(productConfig.getDiscount()).divide(new BigDecimal(100) , 2, RoundingMode.HALF_UP));
if (salePrice.compareTo(jsonObject.getBigDecimal("price")) > 0) {
jsonObject.put("salePrice" , salePrice);
@ -291,11 +323,23 @@ public class CinemaController {
}
}
}
}
if (areaPrices != null) {
for (Object price: areaPrices) {
JSONObject priceObject = (JSONObject) price;
BigDecimal salePrice = priceObject.getBigDecimal("price").add(priceObject.getBigDecimal("qmmPrice").multiply(productConfig.getDiscount()).divide(new BigDecimal(100) , 2, RoundingMode.HALF_UP));
if (salePrice.compareTo(priceObject.getBigDecimal("price")) > 0) {
priceObject.put("salePrice" , salePrice);
} else {
priceObject.put("salePrice" , priceObject.getBigDecimal("price"));
}
object.put("seats" , jsonArray);
}
}
object.put("seats" , jsonArray);
object.put("areaPrices" , areaPrices);
return ResponseMsgUtil.success(object);

@ -80,7 +80,6 @@ public class OrderController {
&& orderChild.getProductSpecId() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
}
body.setUserId(userSession.getUser().getId());

@ -7,7 +7,9 @@ import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsMerPayConfig;
import com.hfkj.entity.BsOrderOutside;
import com.hfkj.entity.BsUserCard;
import com.hfkj.entity.BsUserLoginLog;
import com.hfkj.mer.BsMerPayConfigService;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
@ -15,11 +17,13 @@ import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel;
import com.hfkj.service.card.BsUserCardService;
import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.service.order.BsOrderOutsideService;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.OrderPayService;
import com.hfkj.service.pay.HuiPayService;
import com.hfkj.service.pay.huift.TradeService;
import com.hfkj.service.pay.huift.config.HuiftConfig;
import com.hfkj.service.user.BsUserLoginLogService;
import com.hfkj.sysenum.UserCardTypeEnum;
import com.hfkj.sysenum.mer.PayPlatformEnum;
import com.hfkj.sysenum.order.OrderPayChannelEnum;
@ -37,6 +41,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;
/**
@ -65,6 +70,12 @@ public class OrderPayController {
@Resource
private BsMerPayConfigService merPayConfigService;
@Resource
private BsOrderOutsideService bsOrderOutsideService;
@Resource
private BsUserLoginLogService bsUserLoginLogService;
@RequestMapping(value="/wechat",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "微信")
@ -151,7 +162,7 @@ public class OrderPayController {
@RequestMapping(value="/huiftPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "贵行V家园小程序支付")
@ApiOperation(value = "贵行V家园支付")
public ResponseData huiftPay(@RequestBody JSONObject body) {
try {
if (body == null|| StringUtils.isBlank(body.getString("orderNo"))) {
@ -180,6 +191,25 @@ public class OrderPayController {
orderChild.setSettleAccountKey(HuiftConfig.signSecret);
orderChildService.editData(orderChild);
}
// 插入订单关联
BsUserLoginLog bsUserLoginLog = bsUserLoginLogService.findUserLog(order.getUserId());
BsOrderOutside bsOrderOutside = new BsOrderOutside();
if (bsUserLoginLog != null) {
bsOrderOutside.setPlatformCode(bsOrderOutside.getPlatformCode());
bsOrderOutside.setPlatformName(bsOrderOutside.getPlatformName());
bsOrderOutside.setLoginTypeCode(bsOrderOutside.getLoginTypeCode());
bsOrderOutside.setLoginTypeName(bsOrderOutside.getLoginTypeName());
}
bsOrderOutside.setOrderNo(order.getOrderNo());
bsOrderOutside.setStatus(1);
bsOrderOutside.setCreateTime(new Date());
bsOrderOutside.setUpdateTime(new Date());
bsOrderOutsideService.create(bsOrderOutside);
order.setPayChannelOrderNo(thirdPreOrder.getString("preOrderNo"));
orderService.editData(order);

@ -1,12 +1,15 @@
package com.order.controller.business;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrderCinema;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.qianzhu.channel.CinemaService;
import com.hfkj.service.goods.BsOrderCinemaService;
import com.hfkj.sysenum.SecUserObjectTypeEnum;
import io.swagger.annotations.Api;
@ -82,4 +85,24 @@ public class BsOrderCinemaController {
}
}
@RequestMapping(value="/queryOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询订单")
public ResponseData queryOrder(@RequestParam(value = "orderNo" , required = true) String orderNo) {
try {
BsOrderCinema bsOrderCinema = bsOrderCinemaService.findGoodsOrder(orderNo);
Map<String , Object> map = new HashMap<>();
map.put("orderNo" , bsOrderCinema.getChannelOrderNo());
JSONObject object = CinemaService.getByOrderNo(map);
return ResponseMsgUtil.success(object);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -28,6 +28,11 @@ public class OrderModel extends BsOrder {
*/
private Object business;
/**
* 业务信息订单
*/
private Object businessOrder;
/**
* 子订单列表
*/

@ -203,6 +203,26 @@ public class CinemaService {
}
/**
* @MethodName getByCinemasId
* @Description:根据影院id查询影院
* @param map
* @return: com.alibaba.fastjson.JSONObject
* @Author: Sum1Dream
* @Date: 2024/7/4 下午1:59
*/
public static JSONObject getByCinemasId(Map<String , Object> map) throws Exception {
JSONObject object = QianZhuService.request("/openApi/v1/cinemas/getById" , map);
if (object.getBoolean("success") && object.getInteger("code") == 10000) {
return object;
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!");
}
}
/**
* @MethodName createMovieOrder
* @Description: 创建订单(备用金模式)会直接扣除账户余额最多只能选择 4 个座位

@ -0,0 +1,71 @@
package com.hfkj.service.order;
import com.hfkj.entity.BsOrderOutside;
import java.util.List;
import java.util.Map;
/**
* @ClassName BsOrderOutsideService
* @Author Sum1Dream
* @Description 外部订单关联
* @Date 2024/7/11 11:39
**/
public interface BsOrderOutsideService {
/**
* @MethodName create
* @Description: 创建
* @param orderOutside
* @Author: Sum1Dream
* @Date: 2024/7/11 11:40
*/
void create(BsOrderOutside orderOutside);
/**
* @MethodName update
* @Description: 更新
* @param orderOutside
* @Author: Sum1Dream
* @Date: 2024/7/11 11:40
*/
void update(BsOrderOutside orderOutside);
/**
* @MethodName delete
* @Description: 删除
* @param id
* @param fullDelete
* @Author: Sum1Dream
* @Date: 2024/7/11 11:40
*/
void delete(Long id , Boolean fullDelete);
/**
* @MethodName queryDetail
* @Description:查询详情
* @param id
* @return: com.hfkj.entity.BsOrderOutside
* @Author: Sum1Dream
* @Date: 2024/7/11 11:40
*/
BsOrderOutside queryDetail(Long id);
/**
* @MethodName queryDetailByMap
* @Description: 根据map查询
* @param map
* @return: com.hfkj.entity.BsOrderOutside
* @Author: Sum1Dream
* @Date: 2024/7/11 11:40
*/
BsOrderOutside queryDetailByMap(Map<String , Object> map);
/**
* @MethodName getList
* @Description: 查询列表
* @param map
* @return: java.util.List<com.hfkj.entity.BsOrderOutside>
* @Author: Sum1Dream
* @Date: 2024/7/11 11:41
*/
List<BsOrderOutside> getList(Map<String , Object> map);
}

@ -93,6 +93,6 @@ public interface BsOrderService {
* @Author: Sum1Dream
* @Date: 2024/7/5 下午3:40
*/
BigDecimal cinemaComputePrice(JSONArray jsonArray, String[] seatsIdArray);
BigDecimal cinemaComputePrice(JSONArray jsonArray, String[] seatsIdArray , Integer drawMode);
}

@ -257,6 +257,7 @@ public class OrderCreateService {
if (object == null ||
object.getLong("filmId") == null ||
object.getLong("showId") == null ||
object.getInteger("drawMode") == null ||
object.getBoolean("acceptAdjust") == null ||
StringUtils.isBlank(object.getString("seats")) ||
StringUtils.isBlank(object.getString("phone")) ||
@ -295,7 +296,7 @@ public class OrderCreateService {
String[] seatsIdArray = object.getString("seats").split(",");
orderChild.setProductPrice(bsOrderService.cinemaComputePrice(jsonArray , seatsIdArray));
orderChild.setProductPrice(bsOrderService.cinemaComputePrice(jsonArray , seatsIdArray , object.getInteger("drawMode")));
// 创建电影票订单实体
BsOrderCinema bsOrderCinema = new BsOrderCinema();
@ -311,7 +312,7 @@ public class OrderCreateService {
bsOrderCinema.setShowId(object.getLong("showId"));
bsOrderCinema.setFilmId(object.getInteger("filmId"));
bsOrderCinema.setAcceptAdjust(object.getBoolean("acceptAdjust"));
bsOrderCinema.setDrawMode(0);
bsOrderCinema.setDrawMode(object.getInteger("drawMode"));
bsOrderCinema.setSeatsCount(seatsIdArray.length);
bsOrderCinema.setSeats(object.getString("seatsName"));
bsOrderCinema.setCreateTime(new Date());

@ -254,6 +254,18 @@ public class OrderPaySuccessService {
orderCinema.setChannelOrderNo(jsonObject.getJSONObject("data").getString("orderNo"));
orderCinema.setUpdateTime(new Date());
orderCinema.setTotalPrice(childOrder.getProductTotalPrice());
orderCinema.setTotalDeductionPrice(childOrder.getTotalDeductionPrice());
orderCinema.setCouponDiscountPrice(childOrder.getCouponDiscountPrice());
orderCinema.setIntegralDiscountPrice(childOrder.getIntegralDiscountPrice());
orderCinema.setPayRealPrice(childOrder.getSurplusRefundPrice());
orderCinema.setPayChannel(order.getPayChannel());
orderCinema.setPayType(order.getPayType());
orderCinema.setPaySerialNo(order.getPaySerialNo());
orderCinema.setPayTime(order.getPayTime());
orderCinema.setUpdateTime(new Date());
orderCinema.setStatus(1);
} catch (Exception e) {
orderCinema.setExceptionStatus(true);
orderCinema.setExceptionMsg(e.getMessage());
@ -261,9 +273,6 @@ public class OrderPaySuccessService {
bsOrderCinemaService.update(orderCinema);
}
}
}

@ -0,0 +1,55 @@
package com.hfkj.service.order.impl;
import com.hfkj.dao.BsOrderOutsideMapper;
import com.hfkj.entity.BsOrderGoods;
import com.hfkj.entity.BsOrderOutside;
import com.hfkj.service.order.BsOrderOutsideService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service("bsOrderOutsideService")
public class BsOrderOutsideServiceImpl implements BsOrderOutsideService {
@Resource
private BsOrderOutsideMapper bsOrderOutsideMapper;
@Override
public void create(BsOrderOutside orderOutside) {
bsOrderOutsideMapper.insert(orderOutside);
}
@Override
public void update(BsOrderOutside orderOutside) {
bsOrderOutsideMapper.updateByPrimaryKey(orderOutside);
}
@Override
public void delete(Long id, Boolean fullDelete) {
if (fullDelete) {
bsOrderOutsideMapper.deleteByPrimaryKey(id);
} else {
BsOrderOutside orderOutside = queryDetail(id);
orderOutside.setStatus(0);
orderOutside.setUpdateTime(new Date());
update(orderOutside);
}
}
@Override
public BsOrderOutside queryDetail(Long id) {
return bsOrderOutsideMapper.selectByPrimaryKey(id);
}
@Override
public BsOrderOutside queryDetailByMap(Map<String, Object> map) {
return null;
}
@Override
public List<BsOrderOutside> getList(Map<String, Object> map) {
return null;
}
}

@ -41,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@ -496,8 +497,6 @@ public class BsOrderServiceImpl implements BsOrderService {
}
if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type3.getCode())) {
BsOrderCinema bsOrderCinema = bsOrderCinemaService.findGoodsOrder(orderNo);
Map<String , Object> map = new HashMap<>();
@ -508,6 +507,7 @@ public class BsOrderServiceImpl implements BsOrderService {
bsOrderCinema.setStatus(object.getJSONObject("data").getInteger("status"));
}
orderModel.setBusinessOrder(bsOrderCinema);
bsOrderCinemaService.update(bsOrderCinema);
@ -574,11 +574,12 @@ public class BsOrderServiceImpl implements BsOrderService {
}
@Override
public BigDecimal cinemaComputePrice(JSONArray jsonArray, String[] seatsIdArray) {
public BigDecimal cinemaComputePrice(JSONArray jsonArray, String[] seatsIdArray , Integer drawMode) {
BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type3.getCode());
BigDecimal totalPrice = new BigDecimal(0);
BigDecimal totalSalePrice = new BigDecimal(0);
BigDecimal totalDrawModePrice = new BigDecimal(0);
for (String string : seatsIdArray) {
Integer seatsId = Integer.valueOf(string);
@ -588,7 +589,7 @@ public class BsOrderServiceImpl implements BsOrderService {
for (Object s : seats) {
JSONObject jsonObject = (JSONObject) s;
if (jsonObject != null) {
BigDecimal salePrice = jsonObject.getBigDecimal("fastDrawModePrice").multiply(productConfig.getDiscount()).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
BigDecimal salePrice = jsonObject.getBigDecimal("price").add(jsonObject.getBigDecimal("fastDrawModePrice").multiply(productConfig.getDiscount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP));
if (salePrice.compareTo(jsonObject.getBigDecimal("price")) > 0) {
jsonObject.put("salePrice", salePrice);
@ -597,7 +598,8 @@ public class BsOrderServiceImpl implements BsOrderService {
}
if (Objects.equals(jsonObject.getInteger("id"), seatsId)) {
totalPrice = totalPrice.add(jsonObject.getBigDecimal("salePrice"));
totalSalePrice = totalSalePrice.add(jsonObject.getBigDecimal("salePrice"));
totalDrawModePrice = totalDrawModePrice.add(jsonObject.getBigDecimal("fastDrawModePrice"));
}
}
@ -606,6 +608,12 @@ public class BsOrderServiceImpl implements BsOrderService {
}
}
return totalPrice;
if (drawMode == 0 ) {
return totalSalePrice;
} else {
return totalDrawModePrice;
}
}
}

@ -34,4 +34,6 @@ public interface BsUserLoginLogService {
* @return
*/
List<BsUserLoginLog> getLogList(Map<String, Object> param);
BsUserLoginLog findUserLog(Long userId);
}

@ -35,6 +35,13 @@ public interface BsUserService {
*/
BsUser getUser(String phone);
/**
* 获取用户
* @param vFamilyOpenid 手机号
* @return
*/
BsUser getUserByVFamilyOpenid(String vFamilyOpenid);
/**
* 获取用户列表
@ -53,6 +60,15 @@ public interface BsUserService {
*/
BsUser register(String phone,String password, Map<String, Object> other);
/**
* 用户注册
* @param vFamilyOpenid v家园
* @param other 其他参数
* @return
* @throws Exception
*/
BsUser register(String vFamilyOpenid, Map<String, Object> other);
/**
* 用户登录
* @param platform 客户端
@ -65,6 +81,17 @@ public interface BsUserService {
*/
SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String phone, String password, Map<String, Object> other) throws Exception;
/**
* 用户登录
* @param platform 客户端
* @param loginType 登录方式
* @param outsideOpenid 外部openid
* @param other 其他参数
* @return
* @throws Exception
*/
SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String outsideOpenid, Map<String, Object> other) throws Exception;
/**
* 退出登录
* @param token

@ -88,4 +88,19 @@ public class BsUserLoginLogServiceImpl implements BsUserLoginLogService {
example.setOrderByClause("create_time desc");
return userLoginLogMapper.selectByExample(example);
}
@Override
public BsUserLoginLog findUserLog(Long userId) {
BsUserLoginLogExample example = new BsUserLoginLogExample();
example.createCriteria().andUserIdEqualTo(userId);
example.setOrderByClause("create_time desc");
List<BsUserLoginLog> list = userLoginLogMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
}

@ -78,6 +78,19 @@ public class BsUserServiceImpl implements BsUserService {
return null;
}
@Override
public BsUser getUserByVFamilyOpenid(String vFamilyOpenid) {
BsUserExample example = new BsUserExample();
example.createCriteria()
.andVFamilyOpenidEqualTo(vFamilyOpenid)
.andStatusNotEqualTo(UserStatusEnum.status0.getCode());
List<BsUser> list = userMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public List<BsUser> getList(Map<String, Object> param) {
BsUserExample example = new BsUserExample();
@ -128,6 +141,22 @@ public class BsUserServiceImpl implements BsUserService {
return user;
}
@Override
public BsUser register(String outsideOpenid, Map<String, Object> other) {
// 查询手机号
BsUser user = new BsUser();
user.setvFamilyOpenid(outsideOpenid);
user.setIntegral(0L);
user.setWxMaOpenid(MapUtils.getString(other, "maOpenId"));
user.setWxMpOpenid(MapUtils.getString(other, "mpOpenId"));
user.setStatus(UserStatusEnum.status1.getCode());
editData(user);
user.setName("用户"+user.getId());
editData(user);
return user;
}
@Override
public SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String phone, String password, Map<String, Object> other) throws Exception {
// 查询用户
@ -155,6 +184,24 @@ public class BsUserServiceImpl implements BsUserService {
return sessionObject;
}
@Override
public SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String outsideOpenid, Map<String, Object> other) throws Exception {
BsUser user = getUserByVFamilyOpenid(outsideOpenid);
if (user == null ) {
user = register(outsideOpenid, other);
}
// 缓存
UserSessionObject session = new UserSessionObject();
session.setUser(user);
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
public void loginOut(String token) {
userCenter.remove(token);

@ -11,6 +11,8 @@ import java.util.Objects;
public enum UserLoginPlatform {
H5("H5", "H5客户端"),
WXAPPLETS("WXAPPLETS", "微信小程序"),
VFAMILY("VFAMILY", "V家园"),
GZGOV("GZGOV", "省自机关"),
;
private String code;

@ -14,6 +14,8 @@ public enum UserLoginType {
WECHAT_MA_PHONE("WECHAT_MA_PHONE", "微信小程序手机号"),
WECHAT_MA_OPENID("WECHAT_MA_OPENID", "微信小程序openId"),
WECHAT_MP_OPENID("WECHAT_MP_OPENID", "微信公众号openId"),
V_FAMILY_OPENID("V_FAMILY_OPENID", "V家园openId"),
GZ_GOV_OPENID("GZ_GOV_OPENID", "省自机关openId"),
;
private String code;

@ -23,6 +23,7 @@ import org.apache.catalina.User;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Description;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -115,6 +116,49 @@ public class BsUserController {
}
}
@RequestMapping(value = "/outsideOpenid", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "外部openid登录")
public ResponseData outsideOpenid(@RequestBody JSONObject body) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("platform"))
|| StringUtils.isBlank(body.getString("type"))
|| StringUtils.isBlank(body.getString("outsideOpenid"))
) {
log.error("LoginController --> phone() error!", "请求参数校验失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
String vFamilyOpenid = body.getString("vFamilyOpenid");
// 客户端
UserLoginPlatform platform = UserLoginPlatform.getDataByType(body.getString("platform"));
if (platform == null) {
log.error("LoginController --> phone() error!", "未知客户端");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端");
}
// 登录类型
UserLoginType loginType = UserLoginType.getDataByType(body.getString("type"));
if (loginType == null) {
log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type"));
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型");
}
// 账户密码登录
if (body.getString("type").equals(UserLoginType.V_FAMILY_OPENID.getCode())) {
Map<String, Object> other = new HashMap<>();
return ResponseMsgUtil.success(userService.login(platform, loginType, vFamilyOpenid, other));
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败");
} catch (Exception e) {
log.error("LoginController --> phone() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/phoneTest", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "手机号登录")

Loading…
Cancel
Save