From 80722cf47c53ee8926c14fdfe1fdb43ab70d1ca2 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Thu, 11 Jul 2024 15:01:44 +0800 Subject: [PATCH] 1 --- .../controller/qianZhu/CinemaController.java | 48 ++++++++++++- .../com/order/controller/OrderController.java | 1 - .../order/controller/OrderPayController.java | 32 ++++++++- .../business/BsOrderCinemaController.java | 23 ++++++ .../java/com/hfkj/model/order/OrderModel.java | 5 ++ .../hfkj/qianzhu/channel/CinemaService.java | 20 ++++++ .../service/order/BsOrderOutsideService.java | 71 +++++++++++++++++++ .../hfkj/service/order/BsOrderService.java | 2 +- .../service/order/OrderCreateService.java | 5 +- .../service/order/OrderPaySuccessService.java | 15 +++- .../order/impl/BsOrderOutsideServiceImpl.java | 55 ++++++++++++++ .../order/impl/BsOrderServiceImpl.java | 22 ++++-- .../service/user/BsUserLoginLogService.java | 2 + .../com/hfkj/service/user/BsUserService.java | 27 +++++++ .../user/impl/BsUserLoginLogServiceImpl.java | 15 ++++ .../service/user/impl/BsUserServiceImpl.java | 47 ++++++++++++ .../com/hfkj/sysenum/UserLoginPlatform.java | 2 + .../java/com/hfkj/sysenum/UserLoginType.java | 2 + .../com/user/controller/BsUserController.java | 44 ++++++++++++ 19 files changed, 421 insertions(+), 17 deletions(-) create mode 100644 service/src/main/java/com/hfkj/service/order/BsOrderOutsideService.java create mode 100644 service/src/main/java/com/hfkj/service/order/impl/BsOrderOutsideServiceImpl.java diff --git a/cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java b/cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java index 6ad369b..919e598 100644 --- a/cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java +++ b/cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.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 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("areaPrices" , areaPrices); return ResponseMsgUtil.success(object); diff --git a/order/src/main/java/com/order/controller/OrderController.java b/order/src/main/java/com/order/controller/OrderController.java index b9f9633..b52897f 100644 --- a/order/src/main/java/com/order/controller/OrderController.java +++ b/order/src/main/java/com/order/controller/OrderController.java @@ -80,7 +80,6 @@ public class OrderController { && orderChild.getProductSpecId() == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - } body.setUserId(userSession.getUser().getId()); diff --git a/order/src/main/java/com/order/controller/OrderPayController.java b/order/src/main/java/com/order/controller/OrderPayController.java index 24dcd86..7dacf46 100644 --- a/order/src/main/java/com/order/controller/OrderPayController.java +++ b/order/src/main/java/com/order/controller/OrderPayController.java @@ -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); diff --git a/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java b/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java index dd2de69..559c3c9 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java @@ -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 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); + } + } + } diff --git a/service/src/main/java/com/hfkj/model/order/OrderModel.java b/service/src/main/java/com/hfkj/model/order/OrderModel.java index 7a94d4b..37c3a44 100644 --- a/service/src/main/java/com/hfkj/model/order/OrderModel.java +++ b/service/src/main/java/com/hfkj/model/order/OrderModel.java @@ -28,6 +28,11 @@ public class OrderModel extends BsOrder { */ private Object business; + /** + * 业务信息订单 + */ + private Object businessOrder; + /** * 子订单列表 */ diff --git a/service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java b/service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java index 4e002a7..fbbdcd4 100644 --- a/service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java +++ b/service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java @@ -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 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 个座位 diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderOutsideService.java b/service/src/main/java/com/hfkj/service/order/BsOrderOutsideService.java new file mode 100644 index 0000000..63fe574 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/BsOrderOutsideService.java @@ -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 map); + + /** + * @MethodName getList + * @Description: 查询列表 + * @param map + * @return: java.util.List + * @Author: Sum1Dream + * @Date: 2024/7/11 11:41 + */ + List getList(Map map); +} diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderService.java b/service/src/main/java/com/hfkj/service/order/BsOrderService.java index ec1db47..d0717a4 100644 --- a/service/src/main/java/com/hfkj/service/order/BsOrderService.java +++ b/service/src/main/java/com/hfkj/service/order/BsOrderService.java @@ -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); } diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index 8303ef4..db80d25 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -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()); diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index 02b6987..3b44acc 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -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); } - - - } } diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderOutsideServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderOutsideServiceImpl.java new file mode 100644 index 0000000..6427796 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderOutsideServiceImpl.java @@ -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 map) { + return null; + } + + @Override + public List getList(Map map) { + return null; + } +} diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index 76ad627..8a9edb8 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -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 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; + } + } } diff --git a/service/src/main/java/com/hfkj/service/user/BsUserLoginLogService.java b/service/src/main/java/com/hfkj/service/user/BsUserLoginLogService.java index cd001cc..86b8056 100644 --- a/service/src/main/java/com/hfkj/service/user/BsUserLoginLogService.java +++ b/service/src/main/java/com/hfkj/service/user/BsUserLoginLogService.java @@ -34,4 +34,6 @@ public interface BsUserLoginLogService { * @return */ List getLogList(Map param); + + BsUserLoginLog findUserLog(Long userId); } diff --git a/service/src/main/java/com/hfkj/service/user/BsUserService.java b/service/src/main/java/com/hfkj/service/user/BsUserService.java index 4a66e0f..1aad5f5 100644 --- a/service/src/main/java/com/hfkj/service/user/BsUserService.java +++ b/service/src/main/java/com/hfkj/service/user/BsUserService.java @@ -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 other); + /** + * 用户注册 + * @param vFamilyOpenid v家园 + * @param other 其他参数 + * @return + * @throws Exception + */ + BsUser register(String vFamilyOpenid, Map other); + /** * 用户登录 * @param platform 客户端 @@ -65,6 +81,17 @@ public interface BsUserService { */ SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String phone, String password, Map other) throws Exception; + /** + * 用户登录 + * @param platform 客户端 + * @param loginType 登录方式 + * @param outsideOpenid 外部openid + * @param other 其他参数 + * @return + * @throws Exception + */ + SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String outsideOpenid, Map other) throws Exception; + /** * 退出登录 * @param token diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserLoginLogServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserLoginLogServiceImpl.java index c37e0b5..3998509 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserLoginLogServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserLoginLogServiceImpl.java @@ -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 list = userLoginLogMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + + return null; + } } diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java index 12177c0..56100dd 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java @@ -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 list = userMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } + @Override public List getList(Map param) { BsUserExample example = new BsUserExample(); @@ -128,6 +141,22 @@ public class BsUserServiceImpl implements BsUserService { return user; } + @Override + public BsUser register(String outsideOpenid, Map 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 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 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); diff --git a/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java b/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java index 7420671..d69d297 100644 --- a/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java +++ b/service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java @@ -11,6 +11,8 @@ import java.util.Objects; public enum UserLoginPlatform { H5("H5", "H5客户端"), WXAPPLETS("WXAPPLETS", "微信小程序"), + VFAMILY("VFAMILY", "V家园"), + GZGOV("GZGOV", "省自机关"), ; private String code; diff --git a/service/src/main/java/com/hfkj/sysenum/UserLoginType.java b/service/src/main/java/com/hfkj/sysenum/UserLoginType.java index 20d8795..37deecb 100644 --- a/service/src/main/java/com/hfkj/sysenum/UserLoginType.java +++ b/service/src/main/java/com/hfkj/sysenum/UserLoginType.java @@ -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; diff --git a/user/src/main/java/com/user/controller/BsUserController.java b/user/src/main/java/com/user/controller/BsUserController.java index ddcbb19..68ea932 100644 --- a/user/src/main/java/com/user/controller/BsUserController.java +++ b/user/src/main/java/com/user/controller/BsUserController.java @@ -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 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 = "手机号登录")