提交代码

dev-discount
胡锐 3 years ago
parent 3c5ec2b493
commit 90db938450
  1. 6
      hai-bweb/src/main/java/com/bweb/controller/HighCompanyAmountController.java
  2. 35
      hai-bweb/src/main/java/com/bweb/controller/HighOilCardController.java
  3. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  4. 7
      hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java
  5. 3
      hai-service/src/main/java/com/hai/dao/HighTyAgentOilStationMapperExt.java
  6. 3
      hai-service/src/main/java/com/hai/enum_type/CompanyAmountSourceTypeEnum.java
  7. 2
      hai-service/src/main/java/com/hai/enum_type/OilCardRecordSourceTypeEnum.java
  8. 2
      hai-service/src/main/java/com/hai/service/HighCompanyAccountService.java
  9. 12
      hai-service/src/main/java/com/hai/service/HighOilCardService.java
  10. 7
      hai-service/src/main/java/com/hai/service/impl/HighCompanyAccountServiceImpl.java
  11. 135
      hai-service/src/main/java/com/hai/service/impl/HighOilCardServiceImpl.java
  12. 9
      hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java

@ -10,6 +10,7 @@ import com.hai.common.security.UserCenter;
import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighCompanyAccount;
import com.hai.enum_type.CompanyAmountSourceTypeEnum;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighCompanyAccountRecordService;
@ -70,7 +71,10 @@ public class HighCompanyAmountController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误");
}
companyAccountService.recharge(body.getLong("orgId"), body.getBigDecimal("amount"));
Map<String, Object> map = new HashMap<>();
map.put("sourceType", CompanyAmountSourceTypeEnum.type1.getType());
map.put("sourceContent", "充值金额:" + body.getBigDecimal("amount") + " 元");
companyAccountService.recharge(body.getLong("orgId"), body.getBigDecimal("amount"), map);
return ResponseMsgUtil.success("操作成功");

@ -74,7 +74,7 @@ public class HighOilCardController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_TOW_PWD, "");
}
if (!AESEncodeUtil.aesEncrypt(body.getString("twoPwd")).equals(pwdByOrg.getPassword())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "二级密码错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付密码错误");
}
// 充值
oilCardService.recharge(body.getString("cardNo"), body.getBigDecimal("price"), userModel.getBsOrganization().getId());
@ -87,6 +87,39 @@ public class HighOilCardController {
}
}
@RequestMapping(value = "/recycleAmount", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "回收余额")
public ResponseData recycleAmount(@RequestBody JSONObject body) {
try {
if (StringUtils.isBlank(body.getString("cardNo")) ||
StringUtils.isBlank(body.getString("twoPwd"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class);
if (userModel.getBsOrganization() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "权限不足");
}
// 查询二级密码
HighCompanyTwoPwd pwdByOrg = companyTwoPwdService.getTwoPwdByOrg(userModel.getBsOrganization().getId());
if (pwdByOrg == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_TOW_PWD, "");
}
if (!AESEncodeUtil.aesEncrypt(body.getString("twoPwd")).equals(pwdByOrg.getPassword())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付密码错误");
}
// 充值
oilCardService.recycleAmount(body.getString("cardNo"));
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOilCardController --> recharge() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/generateCard", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "生成油卡")

File diff suppressed because one or more lines are too long

@ -15,8 +15,10 @@ import com.hai.dao.HighGasOrderRefundMapper;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighGasOrderRefund;
import com.hai.entity.HighOrder;
import com.hai.enum_type.OrderPayTypeEnum;
import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData;
import com.hai.service.HighOilCardService;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserService;
import io.swagger.annotations.Api;
@ -52,6 +54,8 @@ public class TuanYouController {
@Resource
private HighUserService highUserService;
@Resource
private HighOilCardService oilCardService;
@RequestMapping(value = "/orderPaymentNotify", method = RequestMethod.POST)
@ApiOperation(value = "订单支付回调")
@ -162,6 +166,9 @@ public class TuanYouController {
highOrderService.updateOrderDetail(order);
}
} else if (order.getPayType().equals(OrderPayTypeEnum.type7.getType())) {
// 油卡退款
oilCardService.refund(order.getOrderNo());
}
} else if (!object.getBoolean("refundResult") == true && order != null) {

@ -64,7 +64,8 @@ public interface HighTyAgentOilStationMapperExt {
" WHEN 3 THEN '金币'" +
" WHEN 4 THEN '汇联通'" +
" WHEN 5 THEN '银联'" +
" WHEN 6 THEN '银联'" +
" WHEN 6 THEN '银联分期'" +
" WHEN 7 THEN '嗨森逛油卡'" +
" ELSE '未知' " +
" END payType," +
" b.total_price totalPrice," +

@ -6,7 +6,8 @@ package com.hai.enum_type;
*/
public enum CompanyAmountSourceTypeEnum {
type1(1, "金额充值"),
type2(2, "油卡充值")
type2(2, "油卡充值"),
type3(3, "回收余额")
;
private Integer type;

@ -7,6 +7,8 @@ package com.hai.enum_type;
public enum OilCardRecordSourceTypeEnum {
type1(1 , "充值金额"),
type2(2 , "订单消费"),
type3(3 , "订单退款"),
type4(4 , "回收余额"),
;
private Integer type;

@ -22,7 +22,7 @@ public interface HighCompanyAccountService {
* @param orgId 单位id
* @param amount 金额
*/
void recharge(Long orgId, BigDecimal amount);
void recharge(Long orgId, BigDecimal amount, Map<String, Object> otherParam);
/**
* 出账

@ -27,6 +27,12 @@ public interface HighOilCardService {
*/
void recharge(String cardNo, BigDecimal price, Long orgId);
/**
* 回收余额
* @param cardNo
*/
void recycleAmount(String cardNo);
/**
* 油卡消费
* @param cardNo 油卡卡号
@ -35,6 +41,12 @@ public interface HighOilCardService {
*/
void consume(String cardNo, BigDecimal amount, Map<String, Object> otherParam);
/**
* 订单退款
* @param orderNo 订单号
*/
void refund(String orderNo);
/**
* 生成油卡
* @param orgId 部门id

@ -63,7 +63,7 @@ public class HighCompanyAccountServiceImpl implements HighCompanyAccountService
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public void recharge(Long orgId, BigDecimal amount) {
public void recharge(Long orgId, BigDecimal amount, Map<String, Object> otherParam) {
// 查询单位
BsOrganization organization = organizationService.findById(orgId);
if (organization == null) {
@ -112,8 +112,9 @@ public class HighCompanyAccountServiceImpl implements HighCompanyAccountService
record.setBeforeAmount(beforeAmount);
record.setAfterAmount(afterAmount);
record.setType(CompanyAmountTypeEnum.type1.getType());
record.setSourceType(CompanyAmountSourceTypeEnum.type1.getType());
record.setSourceContent("充值金额:" + amount + " 元");
record.setSourceType(MapUtils.getInteger(otherParam, "sourceType"));
record.setSourceId(MapUtils.getLong(otherParam, "sourceId"));
record.setSourceContent(MapUtils.getString(otherParam, "sourceContent"));
record.setOpUserId(sessionModel.getSecUser().getId());
record.setOpUserName(sessionModel.getSecUser().getUserName());
companyAccountRecordService.insertRecord(record);

@ -9,10 +9,7 @@ import com.hai.common.utils.BankNumberUtil;
import com.hai.common.utils.DateUtil;
import com.hai.dao.HighOilCardMapper;
import com.hai.entity.*;
import com.hai.enum_type.OilCardBindStatusEnum;
import com.hai.enum_type.OilCardRecordSourceTypeEnum;
import com.hai.enum_type.OilCardRecordTypeEnum;
import com.hai.enum_type.OilCardStatusEnum;
import com.hai.enum_type.*;
import com.hai.model.OilCardOrderModel;
import com.hai.model.UserInfoModel;
import com.hai.service.*;
@ -54,6 +51,12 @@ public class HighOilCardServiceImpl implements HighOilCardService {
@Resource
private HighUserCardService userCardService;
@Resource
private HighUserService userService;
@Resource
private HighOrderService orderService;
@Override
public void editData(HighOilCard oilCard) {
if (oilCard.getId() == null) {
@ -73,14 +76,14 @@ public class HighOilCardServiceImpl implements HighOilCardService {
public synchronized void recharge(String cardNo, BigDecimal price, Long orgId) {
HighOilCard oilCard = getOilCardByCardNo(cardNo);
if (oilCard == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到部门");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡卡号错误");
}
if (!oilCard.getStatus().equals(OilCardStatusEnum.status1.getStatus())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡不处于正常状态");
}
// 账户扣款
Map<String, Object> consumeType = new HashMap<>();
consumeType.put("sourceType", "2");
consumeType.put("sourceType", CompanyAmountSourceTypeEnum.type2);
consumeType.put("sourceId", oilCard.getId());
consumeType.put("sourceContent", "油卡:"+oilCard.getCardNo()+",充值:¥"+price.toString());
companyAccountService.consume(orgId, price, consumeType);
@ -110,6 +113,49 @@ public class HighOilCardServiceImpl implements HighOilCardService {
oilCardRecordService.insertRecord(record);
}
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public synchronized void recycleAmount(String cardNo) {
HighOilCard oilCard = getOilCardByCardNo(cardNo);
if (oilCard == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡卡号错误");
}
if (oilCard.getAmount().compareTo(new BigDecimal("0.01")) == -1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡余额低于¥0.01,无需回收");
}
// 账户进账
Map<String, Object> rechargeType = new HashMap<>();
rechargeType.put("sourceType", CompanyAmountSourceTypeEnum.type3.getType());
rechargeType.put("sourceId", oilCard.getId());
rechargeType.put("sourceContent", "油卡:"+oilCard.getCardNo()+",回收余额:¥" + oilCard.getAmount());
companyAccountService.recharge(oilCard.getOrgId(), oilCard.getAmount(), rechargeType);
// 变更前金额
BigDecimal beforeAmount = oilCard.getAmount();
BigDecimal price = oilCard.getAmount();
// 计算金额
oilCard.setAmount(new BigDecimal("0"));
editData(oilCard);
// 变更后金额
BigDecimal afterAmount = oilCard.getAmount();
HighOilCardRecord record = new HighOilCardRecord();
record.setOilCardId(oilCard.getId());
record.setCardNo(oilCard.getCardNo());
record.setType(OilCardRecordTypeEnum.type2.getType());
record.setAmount(price);
record.setBeforeAmount(beforeAmount);
record.setAfterAmount(afterAmount);
record.setSourceType(OilCardRecordSourceTypeEnum.type4.getType());
try {
record.setSourceOrderNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss"));
} catch (Exception e) {
e.printStackTrace();
}
record.setSourceContent("回收油卡余额:" + price);
oilCardRecordService.insertRecord(record);
}
@Override
public void consume(String cardNo, BigDecimal amount, Map<String, Object> otherParam) {
// 油卡
@ -148,6 +194,61 @@ public class HighOilCardServiceImpl implements HighOilCardService {
oilCardRecordService.insertRecord(record);
}
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public void refund(String orderNo) {
HighOrder order = orderService.getOrderByOrderNo(orderNo);
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的的订单");
}
if (!order.getPayType().equals(OrderPayTypeEnum.type7.getType())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式,不是油卡");
}
if (StringUtils.isBlank(order.getMemCardNo())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油卡卡号");
}
// 查询油卡卡号
HighOilCard oilCard = getOilCardByCardNo(order.getMemCardNo());
if (oilCard == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油卡卡号");
}
// 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款
if (order.getOrderStatus() == 2 || order.getOrderStatus() == 3 || order.getOrderStatus() == 6 || order.getOrderStatus() == 7) {
order.setOrderStatus(4);
order.setRefundTime(new Date());
order.setRefundPrice(order.getPayRealPrice());
orderService.updateOrderDetail(order);
// 变更前金额
BigDecimal beforeAmount = oilCard.getAmount();
// 计算金额
oilCard.setAmount(oilCard.getAmount().add(order.getPayRealPrice()));
oilCard.setAmountConsume(oilCard.getAmountConsume().subtract(order.getPayRealPrice()));
editData(oilCard);
// 变更后金额
BigDecimal afterAmount = oilCard.getAmount();
HighOilCardRecord record = new HighOilCardRecord();
record.setOilCardId(oilCard.getId());
record.setCardNo(oilCard.getCardNo());
record.setType(OilCardRecordTypeEnum.type1.getType());
record.setAmount(order.getPayRealPrice());
record.setBeforeAmount(beforeAmount);
record.setAfterAmount(afterAmount);
record.setSourceType(OilCardRecordSourceTypeEnum.type3.getType());
record.setSourceId(order.getId());
try {
record.setSourceOrderNo(orderNo);
} catch (Exception e) {
e.printStackTrace();
}
record.setSourceContent("订单号:" + orderNo + ",退款金额:" + order.getPayRealPrice());
oilCardRecordService.insertRecord(record);
return;
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态异常");
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void generateCard(Long orgId, Integer generateNum) {
@ -198,6 +299,17 @@ public class HighOilCardServiceImpl implements HighOilCardService {
if (StringUtils.isBlank(oilCard.getContactPhone())) {
oilCardContactRecordService.insert(oilCard.getId(), oilCard.getCardNo(), "新设置:联系人【"+contactName+"】,联系电话【"+contactPhone+"】");
// 根据手机号查询 用户是否存在;存在:自动绑定油卡
HighUser user = userService.findByPhone(contactPhone);
if (user != null) {
if (userCardService.getListByUser(user.getId(),UserCardType.type2.getType()).size() > 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "联系电话已绑定其他油卡");
}
userCardService.bindCard(UserCardType.type2.getType(), oilCard.getCardNo(), user.getId());
oilCard.setBindStatus(1);
oilCard.setBindTime(new Date());
}
} else if (StringUtils.isNotBlank(oilCard.getContactPhone()) && !oilCard.getContactPhone().equals(contactPhone)) {
// 绑定状态 0:未绑定 1:已绑定
if (oilCard.getBindStatus().equals(1)) {
@ -211,6 +323,17 @@ public class HighOilCardServiceImpl implements HighOilCardService {
userCardService.editCard(userCard);
}
}
// 根据手机号查询 用户是否存在;存在:自动绑定油卡
HighUser user = userService.findByPhone(contactPhone);
if (user != null) {
if (userCardService.getListByUser(user.getId(),UserCardType.type2.getType()).size() > 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "联系电话已绑定其他油卡");
}
userCardService.bindCard(UserCardType.type2.getType(), oilCard.getCardNo(), user.getId());
oilCard.setBindStatus(1);
oilCard.setBindTime(new Date());
}
oilCardContactRecordService.insert(oilCard.getId(), oilCard.getCardNo(), "联系信息变更:原联系人【"+oilCard.getContactName()+"】,联系电话【"+oilCard.getContactPhone()+"】。" +
"变跟后联系人【"+contactName+ "】,联系电话【"+contactPhone+"】");
}

@ -9,6 +9,7 @@ import com.hai.common.utils.DateUtil;
import com.hai.dao.HighGoldRecMapper;
import com.hai.dao.HighUserMapper;
import com.hai.entity.*;
import com.hai.enum_type.UserCardType;
import com.hai.model.HighUserModel;
import com.hai.service.*;
import org.apache.commons.lang3.StringUtils;
@ -203,8 +204,16 @@ public class HighUserServiceImpl implements HighUserService {
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertUser(HighUser highUser) {
highUserMapper.insert(highUser);
if (highUser.getPhone() != null) {
HighOilCard oilCard = oilCardService.getOilCardByPhone(highUser.getPhone());
if (oilCard != null) {
highUserCardService.bindCard(UserCardType.type2.getType(), oilCard.getCardNo(), highUser.getId());
}
}
}
@Override

Loading…
Cancel
Save