提交代码

new-dev
胡锐 1 year ago committed by Sum1Dream
parent 6351b1df85
commit d5777d22e9
  1. 27
      hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java
  2. 6
      hai-order/src/main/java/com/web/controller/OrderController.java
  3. 25
      hai-service/src/main/java/com/hai/dao/HighOilCardMapper.java
  4. 14
      hai-service/src/main/java/com/hai/dao/HighOilCardSqlProvider.java
  5. 16
      hai-service/src/main/java/com/hai/entity/HighOilCard.java
  6. 60
      hai-service/src/main/java/com/hai/entity/HighOilCardExample.java
  7. 36
      hai-service/src/main/java/com/hai/enum_type/OilCardGetTypeEnum.java
  8. 1
      hai-service/src/main/java/com/hai/enum_type/OilCardRecordSourceTypeEnum.java
  9. 8
      hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java
  10. 3
      hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java
  11. 14
      hai-service/src/main/java/com/hai/service/HighOilCardService.java
  12. 92
      hai-service/src/main/java/com/hai/service/impl/HighOilCardServiceImpl.java

@ -11,15 +11,13 @@ import com.hai.common.utils.RedisUtil;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.entity.HighFleetOilCard; import com.hai.entity.HighFleetOilCard;
import com.hai.entity.HighOilCard;
import com.hai.entity.HighUser; import com.hai.entity.HighUser;
import com.hai.entity.HighUserCard; import com.hai.entity.HighUserCard;
import com.hai.enum_type.UserCardType; import com.hai.enum_type.UserCardType;
import com.hai.model.HighUserModel; import com.hai.model.HighUserModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.HighFleetOilCardService; import com.hai.service.*;
import com.hai.service.HighUserCardService;
import com.hai.service.HighUserPayPasswordService;
import com.hai.service.HighUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.catalina.User; import org.apache.catalina.User;
@ -59,6 +57,9 @@ public class HighUserCardController {
@Resource @Resource
private HighFleetOilCardService fleetOilCardService; private HighFleetOilCardService fleetOilCardService;
@Resource
private HighOilCardService oilCardService;
@RequestMapping(value = "/bindCard", method = RequestMethod.POST) @RequestMapping(value = "/bindCard", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "绑卡") @ApiOperation(value = "绑卡")
@ -370,4 +371,22 @@ public class HighUserCardController {
} }
} }
@RequestMapping(value = "/applyOilCard", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "申请个人加油卡")
public ResponseData applyOilCard(HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
return ResponseMsgUtil.success(oilCardService.applyOilCard(userInfoModel.getHighUser().getPhone()));
} catch (Exception e) {
log.error("HighUserCardController --> applyOilCard() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -149,6 +149,12 @@ public class OrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择收货地址!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择收货地址!");
} }
} else if (childModel.getGoodsType().equals(OrderChildGoodsType.TYPE14.getNumber())) {
if (childModel.getGoodsSpecName() == null) {
log.error("OrderController -> create() error!","");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入卡号");
}
} }
} }

@ -43,20 +43,20 @@ public interface HighOilCardMapper extends HighOilCardMapperExt {
"org_id, org_name, card_no, ", "org_id, org_name, card_no, ",
"amount, amount_consume, ", "amount, amount_consume, ",
"contact_name, contact_phone, ", "contact_name, contact_phone, ",
"`status`, bind_status, ", "`status`, get_type, ",
"bind_time, create_time, ", "bind_status, bind_time, ",
"update_time, op_user_id, ", "create_time, update_time, ",
"op_user_name, ext_1, ", "op_user_id, op_user_name, ",
"ext_2, ext_3)", "ext_1, ext_2, ext_3)",
"values (#{companyId,jdbcType=BIGINT}, #{companyName,jdbcType=VARCHAR}, ", "values (#{companyId,jdbcType=BIGINT}, #{companyName,jdbcType=VARCHAR}, ",
"#{orgId,jdbcType=BIGINT}, #{orgName,jdbcType=VARCHAR}, #{cardNo,jdbcType=VARCHAR}, ", "#{orgId,jdbcType=BIGINT}, #{orgName,jdbcType=VARCHAR}, #{cardNo,jdbcType=VARCHAR}, ",
"#{amount,jdbcType=DECIMAL}, #{amountConsume,jdbcType=DECIMAL}, ", "#{amount,jdbcType=DECIMAL}, #{amountConsume,jdbcType=DECIMAL}, ",
"#{contactName,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR}, ", "#{contactName,jdbcType=VARCHAR}, #{contactPhone,jdbcType=VARCHAR}, ",
"#{status,jdbcType=INTEGER}, #{bindStatus,jdbcType=INTEGER}, ", "#{status,jdbcType=INTEGER}, #{getType,jdbcType=INTEGER}, ",
"#{bindTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, ", "#{bindStatus,jdbcType=INTEGER}, #{bindTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{opUserId,jdbcType=BIGINT}, ", "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{opUserName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", "#{opUserId,jdbcType=BIGINT}, #{opUserName,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighOilCard record); int insert(HighOilCard record);
@ -78,6 +78,7 @@ public interface HighOilCardMapper extends HighOilCardMapperExt {
@Result(column="contact_name", property="contactName", jdbcType=JdbcType.VARCHAR), @Result(column="contact_name", property="contactName", jdbcType=JdbcType.VARCHAR),
@Result(column="contact_phone", property="contactPhone", jdbcType=JdbcType.VARCHAR), @Result(column="contact_phone", property="contactPhone", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="get_type", property="getType", jdbcType=JdbcType.INTEGER),
@Result(column="bind_status", property="bindStatus", jdbcType=JdbcType.INTEGER), @Result(column="bind_status", property="bindStatus", jdbcType=JdbcType.INTEGER),
@Result(column="bind_time", property="bindTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="bind_time", property="bindTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@ -93,7 +94,7 @@ public interface HighOilCardMapper extends HighOilCardMapperExt {
@Select({ @Select({
"select", "select",
"id, company_id, company_name, org_id, org_name, card_no, amount, amount_consume, ", "id, company_id, company_name, org_id, org_name, card_no, amount, amount_consume, ",
"contact_name, contact_phone, `status`, bind_status, bind_time, create_time, ", "contact_name, contact_phone, `status`, get_type, bind_status, bind_time, create_time, ",
"update_time, op_user_id, op_user_name, ext_1, ext_2, ext_3", "update_time, op_user_id, op_user_name, ext_1, ext_2, ext_3",
"from high_oil_card", "from high_oil_card",
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
@ -110,6 +111,7 @@ public interface HighOilCardMapper extends HighOilCardMapperExt {
@Result(column="contact_name", property="contactName", jdbcType=JdbcType.VARCHAR), @Result(column="contact_name", property="contactName", jdbcType=JdbcType.VARCHAR),
@Result(column="contact_phone", property="contactPhone", jdbcType=JdbcType.VARCHAR), @Result(column="contact_phone", property="contactPhone", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="get_type", property="getType", jdbcType=JdbcType.INTEGER),
@Result(column="bind_status", property="bindStatus", jdbcType=JdbcType.INTEGER), @Result(column="bind_status", property="bindStatus", jdbcType=JdbcType.INTEGER),
@Result(column="bind_time", property="bindTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="bind_time", property="bindTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@ -143,6 +145,7 @@ public interface HighOilCardMapper extends HighOilCardMapperExt {
"contact_name = #{contactName,jdbcType=VARCHAR},", "contact_name = #{contactName,jdbcType=VARCHAR},",
"contact_phone = #{contactPhone,jdbcType=VARCHAR},", "contact_phone = #{contactPhone,jdbcType=VARCHAR},",
"`status` = #{status,jdbcType=INTEGER},", "`status` = #{status,jdbcType=INTEGER},",
"get_type = #{getType,jdbcType=INTEGER},",
"bind_status = #{bindStatus,jdbcType=INTEGER},", "bind_status = #{bindStatus,jdbcType=INTEGER},",
"bind_time = #{bindTime,jdbcType=TIMESTAMP},", "bind_time = #{bindTime,jdbcType=TIMESTAMP},",
"create_time = #{createTime,jdbcType=TIMESTAMP},", "create_time = #{createTime,jdbcType=TIMESTAMP},",

@ -68,6 +68,10 @@ public class HighOilCardSqlProvider {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
} }
if (record.getGetType() != null) {
sql.VALUES("get_type", "#{getType,jdbcType=INTEGER}");
}
if (record.getBindStatus() != null) { if (record.getBindStatus() != null) {
sql.VALUES("bind_status", "#{bindStatus,jdbcType=INTEGER}"); sql.VALUES("bind_status", "#{bindStatus,jdbcType=INTEGER}");
} }
@ -124,6 +128,7 @@ public class HighOilCardSqlProvider {
sql.SELECT("contact_name"); sql.SELECT("contact_name");
sql.SELECT("contact_phone"); sql.SELECT("contact_phone");
sql.SELECT("`status`"); sql.SELECT("`status`");
sql.SELECT("get_type");
sql.SELECT("bind_status"); sql.SELECT("bind_status");
sql.SELECT("bind_time"); sql.SELECT("bind_time");
sql.SELECT("create_time"); sql.SELECT("create_time");
@ -194,6 +199,10 @@ public class HighOilCardSqlProvider {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
} }
if (record.getGetType() != null) {
sql.SET("get_type = #{record.getType,jdbcType=INTEGER}");
}
if (record.getBindStatus() != null) { if (record.getBindStatus() != null) {
sql.SET("bind_status = #{record.bindStatus,jdbcType=INTEGER}"); sql.SET("bind_status = #{record.bindStatus,jdbcType=INTEGER}");
} }
@ -249,6 +258,7 @@ public class HighOilCardSqlProvider {
sql.SET("contact_name = #{record.contactName,jdbcType=VARCHAR}"); sql.SET("contact_name = #{record.contactName,jdbcType=VARCHAR}");
sql.SET("contact_phone = #{record.contactPhone,jdbcType=VARCHAR}"); sql.SET("contact_phone = #{record.contactPhone,jdbcType=VARCHAR}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("get_type = #{record.getType,jdbcType=INTEGER}");
sql.SET("bind_status = #{record.bindStatus,jdbcType=INTEGER}"); sql.SET("bind_status = #{record.bindStatus,jdbcType=INTEGER}");
sql.SET("bind_time = #{record.bindTime,jdbcType=TIMESTAMP}"); sql.SET("bind_time = #{record.bindTime,jdbcType=TIMESTAMP}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
@ -308,6 +318,10 @@ public class HighOilCardSqlProvider {
sql.SET("`status` = #{status,jdbcType=INTEGER}"); sql.SET("`status` = #{status,jdbcType=INTEGER}");
} }
if (record.getGetType() != null) {
sql.SET("get_type = #{getType,jdbcType=INTEGER}");
}
if (record.getBindStatus() != null) { if (record.getBindStatus() != null) {
sql.SET("bind_status = #{bindStatus,jdbcType=INTEGER}"); sql.SET("bind_status = #{bindStatus,jdbcType=INTEGER}");
} }

@ -66,6 +66,11 @@ public class HighOilCard implements Serializable {
*/ */
private Integer status; private Integer status;
/**
* 获取类型 1机构分配 2客户申领
*/
private Integer getType;
/** /**
* 绑定状态 0未绑定 1已绑定 * 绑定状态 0未绑定 1已绑定
*/ */
@ -192,6 +197,14 @@ public class HighOilCard implements Serializable {
this.status = status; this.status = status;
} }
public Integer getGetType() {
return getType;
}
public void setGetType(Integer getType) {
this.getType = getType;
}
public Integer getBindStatus() { public Integer getBindStatus() {
return bindStatus; return bindStatus;
} }
@ -287,6 +300,7 @@ public class HighOilCard implements Serializable {
&& (this.getContactName() == null ? other.getContactName() == null : this.getContactName().equals(other.getContactName())) && (this.getContactName() == null ? other.getContactName() == null : this.getContactName().equals(other.getContactName()))
&& (this.getContactPhone() == null ? other.getContactPhone() == null : this.getContactPhone().equals(other.getContactPhone())) && (this.getContactPhone() == null ? other.getContactPhone() == null : this.getContactPhone().equals(other.getContactPhone()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getGetType() == null ? other.getGetType() == null : this.getGetType().equals(other.getGetType()))
&& (this.getBindStatus() == null ? other.getBindStatus() == null : this.getBindStatus().equals(other.getBindStatus())) && (this.getBindStatus() == null ? other.getBindStatus() == null : this.getBindStatus().equals(other.getBindStatus()))
&& (this.getBindTime() == null ? other.getBindTime() == null : this.getBindTime().equals(other.getBindTime())) && (this.getBindTime() == null ? other.getBindTime() == null : this.getBindTime().equals(other.getBindTime()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
@ -313,6 +327,7 @@ public class HighOilCard implements Serializable {
result = prime * result + ((getContactName() == null) ? 0 : getContactName().hashCode()); result = prime * result + ((getContactName() == null) ? 0 : getContactName().hashCode());
result = prime * result + ((getContactPhone() == null) ? 0 : getContactPhone().hashCode()); result = prime * result + ((getContactPhone() == null) ? 0 : getContactPhone().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getGetType() == null) ? 0 : getGetType().hashCode());
result = prime * result + ((getBindStatus() == null) ? 0 : getBindStatus().hashCode()); result = prime * result + ((getBindStatus() == null) ? 0 : getBindStatus().hashCode());
result = prime * result + ((getBindTime() == null) ? 0 : getBindTime().hashCode()); result = prime * result + ((getBindTime() == null) ? 0 : getBindTime().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
@ -342,6 +357,7 @@ public class HighOilCard implements Serializable {
sb.append(", contactName=").append(contactName); sb.append(", contactName=").append(contactName);
sb.append(", contactPhone=").append(contactPhone); sb.append(", contactPhone=").append(contactPhone);
sb.append(", status=").append(status); sb.append(", status=").append(status);
sb.append(", getType=").append(getType);
sb.append(", bindStatus=").append(bindStatus); sb.append(", bindStatus=").append(bindStatus);
sb.append(", bindTime=").append(bindTime); sb.append(", bindTime=").append(bindTime);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);

@ -836,6 +836,66 @@ public class HighOilCardExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andGetTypeIsNull() {
addCriterion("get_type is null");
return (Criteria) this;
}
public Criteria andGetTypeIsNotNull() {
addCriterion("get_type is not null");
return (Criteria) this;
}
public Criteria andGetTypeEqualTo(Integer value) {
addCriterion("get_type =", value, "getType");
return (Criteria) this;
}
public Criteria andGetTypeNotEqualTo(Integer value) {
addCriterion("get_type <>", value, "getType");
return (Criteria) this;
}
public Criteria andGetTypeGreaterThan(Integer value) {
addCriterion("get_type >", value, "getType");
return (Criteria) this;
}
public Criteria andGetTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("get_type >=", value, "getType");
return (Criteria) this;
}
public Criteria andGetTypeLessThan(Integer value) {
addCriterion("get_type <", value, "getType");
return (Criteria) this;
}
public Criteria andGetTypeLessThanOrEqualTo(Integer value) {
addCriterion("get_type <=", value, "getType");
return (Criteria) this;
}
public Criteria andGetTypeIn(List<Integer> values) {
addCriterion("get_type in", values, "getType");
return (Criteria) this;
}
public Criteria andGetTypeNotIn(List<Integer> values) {
addCriterion("get_type not in", values, "getType");
return (Criteria) this;
}
public Criteria andGetTypeBetween(Integer value1, Integer value2) {
addCriterion("get_type between", value1, value2, "getType");
return (Criteria) this;
}
public Criteria andGetTypeNotBetween(Integer value1, Integer value2) {
addCriterion("get_type not between", value1, value2, "getType");
return (Criteria) this;
}
public Criteria andBindStatusIsNull() { public Criteria andBindStatusIsNull() {
addCriterion("bind_status is null"); addCriterion("bind_status is null");
return (Criteria) this; return (Criteria) this;

@ -0,0 +1,36 @@
package com.hai.enum_type;
/**
* 油卡获取类型
* @author hurui
*/
public enum OilCardGetTypeEnum {
type1(1 , "机构分配"),
type2(2 , "个人申领"),
;
private Integer code;
private String name;
OilCardGetTypeEnum(int status , String name) {
this.code = status;
this.name = name;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -9,6 +9,7 @@ public enum OilCardRecordSourceTypeEnum {
type2(2 , "订单消费"), type2(2 , "订单消费"),
type3(3 , "订单退款"), type3(3 , "订单退款"),
type4(4 , "回收余额"), type4(4 , "回收余额"),
type5(5 , "现金充值"),
; ;
private Integer type; private Integer type;

@ -120,6 +120,8 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
@Resource @Resource
private HighOrderService highOrderService; private HighOrderService highOrderService;
@Resource
private HighOilCardService oilCardService;
@Resource @Resource
private HighOilCardOrderService highOilCardOrderService; private HighOilCardOrderService highOilCardOrderService;
@ -248,6 +250,8 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
blxCouponHandle(order , childOrder); blxCouponHandle(order , childOrder);
} else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE13.getNumber())) { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE13.getNumber())) {
blxOrderHandle(order); blxOrderHandle(order);
} else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE14.getNumber())) {
oilCardHandle(childOrder.getGoodsSpecName(), order);
} else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE14.getNumber())) { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE14.getNumber())) {
levelUp(order); levelUp(order);
} else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE17.getNumber())) { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE17.getNumber())) {
@ -622,6 +626,10 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
} }
private void oilCardHandle(String cardNo, HighOrder order) {
oilCardService.recharge(cardNo, order.getOrderNo());
}
private void levelUp(HighOrder order) { private void levelUp(HighOrder order) {
HighUserLevel userLevel = new HighUserLevel(); HighUserLevel userLevel = new HighUserLevel();

@ -22,7 +22,8 @@ public enum OrderChildGoodsType {
TYPE11(11, "实物商品购买"), TYPE11(11, "实物商品购买"),
TYPE12(12, "比邻星停车券"), TYPE12(12, "比邻星停车券"),
TYPE13(13, "比邻星停车"), TYPE13(13, "比邻星停车"),
TYPE14(14, "升级会员"), TYPE14(14, "个人油卡充值"),
TYPE15(15, "升级会员"),
TYPE17(17, "团购套餐"), TYPE17(17, "团购套餐"),
; ;

@ -19,6 +19,20 @@ public interface HighOilCardService {
*/ */
void editData(HighOilCard oilCard); void editData(HighOilCard oilCard);
/**
* 申请个人油卡
* @param phone
* @return
*/
HighOilCard applyOilCard(String phone);
/**
* 个人油卡现金充值
* @param cardNo
* @param orderNo
*/
void recharge(String cardNo, String orderNo);
/** /**
* 油卡充值 * 油卡充值
* @param cardNo 油卡卡号 * @param cardNo 油卡卡号

@ -72,6 +72,97 @@ public class HighOilCardServiceImpl implements HighOilCardService {
} }
} }
@Override
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
public HighOilCard applyOilCard(String phone) {
if (getOilCardByPhone(phone) != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法申领,手机号【"+phone+"】的油卡已存在");
}
// 查询用户
HighUser user = userService.findByPhone(phone);
if (user == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户不存在");
}
// 查询部门信息,个人油卡部门
BsOrganization organization = organizationService.findById(5L);
if (organization == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到部门");
}
BsCompany company = companyService.getCompanyById(organization.getCompanyId());
// 生成油卡
HighOilCard oilCard = new HighOilCard();
oilCard.setCompanyId(organization.getCompanyId());
oilCard.setCompanyName(company.getName());
oilCard.setOrgId(organization.getId());
oilCard.setOrgName(organization.getName());
oilCard.setAmount(new BigDecimal("0"));
oilCard.setAmountConsume(new BigDecimal("0"));
oilCard.setCardNo(BankNumberUtil.getBrankNumber("8"));
oilCard.setOpUserId(user.getId());
oilCard.setOpUserName(user.getName());
oilCard.setCreateTime(new Date());
oilCard.setUpdateTime(new Date());
oilCard.setStatus(OilCardStatusEnum.status1.getStatus());
oilCard.setBindStatus(OilCardBindStatusEnum.status1.getStatus());
oilCard.setBindTime(new Date());
oilCard.setGetType(OilCardGetTypeEnum.type2.getCode());
editData(oilCard);
// 绑定用户
userCardService.bindCard(UserCardType.type2.getType(), oilCard.getCardNo(), user.getId());
return oilCard;
}
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public void recharge(String cardNo, String orderNo) {
// 查询订单
HighOrder order = orderService.getOrderByOrderNo(orderNo);
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单");
}
if (!order.getOrderStatus().equals(OrderStatusEnum.type2.getType())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误");
}
HighOilCard oilCard = getOilCardByCardNo(cardNo);
if (oilCard == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡卡号错误");
}
if (!oilCard.getStatus().equals(OilCardStatusEnum.status1.getStatus())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡不处于正常状态");
}
// 变更前金额
BigDecimal beforeAmount = oilCard.getAmount();
// 计算金额
oilCard.setAmount(oilCard.getAmount().add(order.getTotalPrice()));
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.getTotalPrice());
record.setBeforeAmount(beforeAmount);
record.setAfterAmount(afterAmount);
record.setSourceType(OilCardRecordSourceTypeEnum.type5.getType());
try {
record.setSourceOrderNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss"));
} catch (Exception e) {
e.printStackTrace();
}
record.setSourceContent("充值油卡金额:" + record.getAmount());
oilCardRecordService.insertRecord(record);
order.setOrderStatus(OrderStatusEnum.type3.getType());
order.setFinishTime(new Date());
orderService.updateOrder(order);
}
@Override @Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW) @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public synchronized void recharge(String cardNo, BigDecimal price, Long orgId) { public synchronized void recharge(String cardNo, BigDecimal price, Long orgId) {
@ -284,6 +375,7 @@ public class HighOilCardServiceImpl implements HighOilCardService {
oilCard.setUpdateTime(new Date()); oilCard.setUpdateTime(new Date());
oilCard.setStatus(OilCardStatusEnum.status1.getStatus()); oilCard.setStatus(OilCardStatusEnum.status1.getStatus());
oilCard.setBindStatus(OilCardBindStatusEnum.status0.getStatus()); oilCard.setBindStatus(OilCardBindStatusEnum.status0.getStatus());
oilCard.setGetType(OilCardGetTypeEnum.type1.getCode());
oilCardList.add(oilCard); oilCardList.add(oilCard);
} }
oilCardMapper.insertList(oilCardList); oilCardMapper.insertList(oilCardList);

Loading…
Cancel
Save