提交代码

master
胡锐 6 months ago
parent f2f28b402f
commit 71a6abe081
  1. 23
      cweb/src/main/java/com/cweb/controller/order/BsOrderController.java
  2. 76
      cweb/src/main/java/com/cweb/controller/order/GasOrderController.java
  3. 2
      cweb/src/main/java/com/cweb/controller/order/OrderPayController.java
  4. 9
      service/src/main/java/com/hfkj/model/SecUserSessionObject.java
  5. 5
      service/src/main/java/com/hfkj/model/order/OrderChildModel.java
  6. 4
      service/src/main/java/com/hfkj/service/gas/impl/BsGasOrderServiceImpl.java
  7. 4
      service/src/main/java/com/hfkj/service/order/OrderCreateService.java
  8. 26
      service/src/main/java/com/hfkj/service/sec/impl/SecUserServiceImpl.java

@ -1,6 +1,8 @@
package com.cweb.controller.order;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
@ -8,6 +10,7 @@ import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsMerchant;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel;
import com.hfkj.service.BsMerchantService;
@ -22,6 +25,8 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value = "/order")
@ -40,23 +45,36 @@ public class BsOrderController {
@ApiOperation(value = "创建订单")
public ResponseData create(@RequestBody OrderModel body) {
try {
// 用户信息
try {
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession != null) {
body.setUserId(userSession.getUser().getId());
body.setUserName(userSession.getUser().getUserName());
body.setUserPhone(userSession.getUser().getPhone());
}
} catch (Exception e) {
// 不做任何处理
}
if (body == null || body.getOrderChildList().isEmpty()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 子订单必填项校验
for (OrderChildModel orderChild : body.getOrderChildList()) {
if (orderChild.getProductType() == null || orderChild.getProductId() == null) {
if (orderChild.getProductType() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) {
if (orderChild.getProductPrice() == null
|| StringUtils.isBlank(orderChild.getGasOilNo())
|| StringUtils.isBlank(orderChild.getGasGunNo())
|| StringUtils.isBlank(orderChild.getMerNo())
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询油站
BsMerchant merchant = merchantService.getMerchant(orderChild.getProductId());
BsMerchant merchant = merchantService.getMerchant(orderChild.getMerNo());
if (merchant == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油站");
}
@ -105,4 +123,5 @@ public class BsOrderController {
}
}
}

@ -0,0 +1,76 @@
package com.cweb.controller.order;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.service.gas.BsGasOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value = "/gasOrder")
@Api(value = "加油订单业务")
public class GasOrderController {
private static Logger log = LoggerFactory.getLogger(GasOrderController.class);
@Resource
private UserCenter userCenter;
@Resource
private BsGasOrderService gasOrderService;
@RequestMapping(value="/queryUserOilOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询用户加油订单")
public ResponseData queryUserOilOrder(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "orderStatus", required = false) Integer orderStatus,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize) {
try {
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class);
if (userSession == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
Map<String,Object> param = new HashMap<>();
param.put("userId", userSession.getUser().getId());
param.put("orderNo", orderNo);
param.put("orderStatus", orderStatus);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(gasOrderService.getGasOrderList(param)));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryOilOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询加油订单详情")
public ResponseData queryOilOrder(@RequestParam(name = "orderNo", required = true) String orderNo) {
try {
return ResponseMsgUtil.success(gasOrderService.getDetailByOrderNo(orderNo));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -72,6 +72,7 @@ public class OrderPayController {
if (merPay == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付");
}
order.setPayType(OrderPayTypeEnum.type1.getCode());
// 请求支付渠道
Map<Object, Object> preorder = HuiPayService.preorder(merPay.getChannelMerNo(), merPay.getChannelMerKey(), body.getString("userId"), order);
@ -108,6 +109,7 @@ public class OrderPayController {
if (merPay == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付");
}
order.setPayType(OrderPayTypeEnum.type2.getCode());
// 请求支付渠道
Map<Object, Object> preorder = HuiPayService.preorder(merPay.getChannelMerNo(), merPay.getChannelMerKey(), body.getString("userId"), order);

@ -1,5 +1,6 @@
package com.hfkj.model;
import com.hfkj.entity.BsMerchant;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecUser;
@ -23,6 +24,11 @@ public class SecUserSessionObject {
*/
private SecRole role;
/**
* 商户
*/
private BsMerchant merchant;
/**
* 菜单
*/
@ -33,9 +39,10 @@ public class SecUserSessionObject {
*/
private List<SecMenu> button;
public SecUserSessionObject(SecUser account, SecRole role, List<MenuTreeModel> menuTree, List<SecMenu> button){
public SecUserSessionObject(SecUser account, SecRole role, BsMerchant merchant, List<MenuTreeModel> menuTree, List<SecMenu> button){
this.account = account;
this.role = role;
this.merchant = merchant;
this.menuTree = menuTree;
this.button = button;
}

@ -11,7 +11,10 @@ import lombok.Data;
**/
@Data
public class OrderChildModel extends BsOrderChild {
/**
* 油站编号
*/
private String merNo;
/**
* 油站加油员
*/

@ -85,6 +85,10 @@ public class BsGasOrderServiceImpl implements BsGasOrderService {
criteria.andOrderChildNoLike("%"+MapUtils.getString(param, "orderChildNo")+"%");
}
if (MapUtils.getLong(param, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId"));
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "userPhone"))) {
criteria.andUserPhoneLike("%"+MapUtils.getString(param, "userPhone")+"%");
}

@ -53,7 +53,7 @@ public class OrderCreateService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知油品类型");
}
// 查询油站
BsMerchant merchant = merchantService.getMerchant(orderChild.getProductId());
BsMerchant merchant = merchantService.getMerchant(orderChild.getMerNo());
if (merchant == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油站");
}
@ -64,6 +64,7 @@ public class OrderCreateService {
GasPayPriceModel priceModel = gasService.refuelPriceCompute(orderChild.getProductPrice(), merchant.getMerNo(), orderChild.getGasOilNo(),false);
BsGasOrder gasOrder = new BsGasOrder();
gasOrder.setMerNo(merchant.getMerNo());
gasOrder.setChannelType(merchant.getSourceType());
gasOrder.setOrderNo(orderChild.getOrderNo());
gasOrder.setOrderChildNo(orderChild.getChildOrderNo());
@ -121,6 +122,7 @@ public class OrderCreateService {
gasOrderService.addGasOrder(gasOrder);
orderChild.setMerNo(merchant.getMerNo());
orderChild.setProductName(merchant.getMerName());
orderChild.setProductImg(merchant.getMerLogo());
orderChild.setProductSpecName("默认");

@ -8,12 +8,11 @@ import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.MD5Util;
import com.hfkj.dao.SecUserMapper;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecUser;
import com.hfkj.entity.SecUserExample;
import com.hfkj.entity.*;
import com.hfkj.model.MenuTreeModel;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.BsMerchantService;
import com.hfkj.service.gas.BsGasStaffService;
import com.hfkj.service.sec.SecMenuService;
import com.hfkj.service.sec.SecRoleService;
import com.hfkj.service.sec.SecUserLoginLogService;
@ -51,6 +50,10 @@ public class SecUserServiceImpl implements SecUserService {
private SecRoleService secRoleService;
@Resource
private SecMenuService secMenuService;
@Resource
private BsMerchantService merchantService;
@Resource
private BsGasStaffService gasStaffService;
@Override
public void editUser(SecUser data) {
@ -162,10 +165,23 @@ public class SecUserServiceImpl implements SecUserService {
// 角色按钮
List<SecMenu> button = secMenuService.queryRoleMenu(role.getId(), SecMenuTypeEnum.type2);
// 获取商户信息
BsMerchant merchant = null;
if (user.getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())){
merchant = merchantService.getMerchant(user.getObjectId());
} else if (user.getObjectType().equals(SecUserObjectTypeEnum.type3.getCode())){
// 查询油站员工
BsGasStaff gasStaff = gasStaffService.getStaffDetailById(user.getObjectId());
if (gasStaff != null) {
merchant = merchantService.getMerchant(gasStaff.getMerId());
}
}
// token 生成格式:账户id + 时间戳
String token = AESEncodeUtil.aesEncrypt(user.getId()+"_"+System.currentTimeMillis(), "O8gTZ6wIovDPjhsaz0zAoqZmm3jtjIcO");
SessionObject sessionObject = new SessionObject(token, new SecUserSessionObject(user, role, menuTree, button));
SessionObject sessionObject = new SessionObject(token, new SecUserSessionObject(user, role, merchant, menuTree, button));
userCenter.save(sessionObject);
// 异步记录登录信息

Loading…
Cancel
Save