diff --git a/bweb/src/main/java/com/bweb/controller/BsGasStaffController.java b/bweb/src/main/java/com/bweb/controller/BsGasStaffController.java index b9b75ac..886e6f3 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasStaffController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasStaffController.java @@ -49,8 +49,6 @@ public class BsGasStaffController { @Resource private BsGasStaffService gasStaffService; @Resource - private BsMerchantService merchantService; - @Resource private CommonService commonService; @Resource private UserCenter userCenter; @@ -163,13 +161,8 @@ public class BsGasStaffController { if (body.getLong("staffId") == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - // 查询油站员工 - BsGasStaff gasStaff = gasStaffService.getStaffDetailById(body.getLong("staffId")); - if (gasStaff == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工"); - } - gasStaff.setStatus(GasStaffStatus.status2.getStatus()); - gasStaffService.editData(gasStaff); + + gasStaffService.disabled(body.getLong("staffId")); return ResponseMsgUtil.success("操作成功"); @@ -187,13 +180,9 @@ public class BsGasStaffController { if (body.getLong("staffId") == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - // 查询油站员工 - BsGasStaff gasStaff = gasStaffService.getStaffDetailById(body.getLong("staffId")); - if (gasStaff == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工"); - } - gasStaff.setStatus(GasStaffStatus.status1.getStatus()); - gasStaffService.editData(gasStaff); + + gasStaffService.recover(body.getLong("staffId")); + return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { diff --git a/bweb/src/main/java/com/bweb/controller/BsOrderRefundController.java b/bweb/src/main/java/com/bweb/controller/BsOrderRefundController.java index 99275d5..f49bf39 100644 --- a/bweb/src/main/java/com/bweb/controller/BsOrderRefundController.java +++ b/bweb/src/main/java/com/bweb/controller/BsOrderRefundController.java @@ -107,6 +107,7 @@ public class BsOrderRefundController { if (refund == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的退款"); } + refund.setAccountMerchantKey(null); Map map = new HashMap<>(); map.put("refund", refund); @@ -156,7 +157,11 @@ public class BsOrderRefundController { param.put("createTimeE", createTimeE); PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(orderRefundService.getRefundList(param))); + PageInfo pageInfo = new PageInfo<>(orderRefundService.getRefundList(param)); + for (BsOrderRefund orderRefund : pageInfo.getList()) { + orderRefund.setAccountMerchantKey(null); + } + return ResponseMsgUtil.success(pageInfo); } catch (Exception e) { log.error("error!",e); diff --git a/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java b/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java index c2de1ca..e0f158f 100644 --- a/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java +++ b/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java @@ -16,6 +16,7 @@ import com.hfkj.pay.HuiPayService; import com.hfkj.service.BsMerchantPayConfigService; import com.hfkj.service.order.BsOrderChildService; import com.hfkj.service.order.BsOrderService; +import com.hfkj.service.order.BsOrderSettleService; import com.hfkj.sysenum.order.OrderPayTypeEnum; import com.hfkj.sysenum.order.OrderStatusEnum; import io.swagger.annotations.Api; @@ -47,6 +48,8 @@ public class OrderPayController { private BsOrderService orderService; @Resource private BsMerchantPayConfigService merPayConfigService; + @Resource + private BsOrderSettleService orderSettleService; @RequestMapping(value="/wechat",method = RequestMethod.POST) @ResponseBody @@ -78,12 +81,17 @@ public class OrderPayController { Map preorder = HuiPayService.preorder(merPay.getChannelMerNo(), merPay.getChannelMerKey(), body.getString("openId"), merPay.getLedgerAccountFlag(), order); // 交易入账 - BsOrderSettle orderSettle = new BsOrderSettle(); + BsOrderSettle orderSettle = orderSettleService.getData(order.getOrderNo()); + if (orderSettle == null) { + orderSettle = new BsOrderSettle(); + } orderSettle.setOrderNo(order.getOrderNo()); orderSettle.setSettleMerNo(merPay.getChannelMerNo()); orderSettle.setSettleMerKey(merPay.getChannelMerKey()); orderSettle.setSettleAmount(order.getPayRealPrice()); orderSettle.setLedgerFlag(merPay.getLedgerAccountFlag()); + orderSettleService.editData(orderSettle); + return ResponseMsgUtil.success(preorder); } catch (Exception e) { @@ -121,6 +129,18 @@ public class OrderPayController { // 请求支付渠道 Map preorder = HuiPayService.preorder(merPay.getChannelMerNo(), merPay.getChannelMerKey(), body.getString("userId"), merPay.getLedgerAccountFlag(), order); + // 交易入账 + BsOrderSettle orderSettle = orderSettleService.getData(order.getOrderNo()); + if (orderSettle == null) { + orderSettle = new BsOrderSettle(); + } + orderSettle.setOrderNo(order.getOrderNo()); + orderSettle.setSettleMerNo(merPay.getChannelMerNo()); + orderSettle.setSettleMerKey(merPay.getChannelMerKey()); + orderSettle.setSettleAmount(order.getPayRealPrice()); + orderSettle.setLedgerFlag(merPay.getLedgerAccountFlag()); + orderSettleService.editData(orderSettle); + return ResponseMsgUtil.success(preorder); } catch (Exception e) { log.error("error!",e); diff --git a/cweb/src/main/java/com/cweb/controller/order/OrderPayNotifyController.java b/cweb/src/main/java/com/cweb/controller/order/OrderPayNotifyController.java index e170641..20177fe 100644 --- a/cweb/src/main/java/com/cweb/controller/order/OrderPayNotifyController.java +++ b/cweb/src/main/java/com/cweb/controller/order/OrderPayNotifyController.java @@ -51,10 +51,10 @@ public class OrderPayNotifyController { // 支付方式 微信:WECHAT 支付宝:ALIPAY 银联:UQRCODEPAY String payMode = dataObject.getString("payMode"); if ("WECHAT".equals(payMode)) { - order.setPayType(OrderPayTypeEnum.type1.getCode()); + order.setPayType(OrderPayTypeEnum.type2.getCode()); } else if ("ALIPAY".equals(payMode)) { - order.setPayType(OrderPayTypeEnum.type2.getCode()); + order.setPayType(OrderPayTypeEnum.type1.getCode()); } order.setPayChannel(OrderPayChannelEnum.type1.getCode()); order.setPayTime(new Date(dataObject.getLong("payTime"))); diff --git a/schedule/src/main/resources/dev/application.yml b/schedule/src/main/resources/dev/application.yml index 91a4d85..9ade586 100644 --- a/schedule/src/main/resources/dev/application.yml +++ b/schedule/src/main/resources/dev/application.yml @@ -1,5 +1,5 @@ server: - port: 9303 + port: 9803 servlet: context-path: /schedule @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://139.9.154.68:3306/hai_oil?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource @@ -27,10 +27,9 @@ spring: testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20 - redis: - database: 0 - host: 139.159.177.244 + database: 2 + host: 139.9.154.68 port: 36379 password: HF123456.Redis timeout: 1000 @@ -40,20 +39,53 @@ spring: max-wait: -1 max-idle: 10 min-idle: 0 + #配置日期返回至前台为时间戳 + jackson: + serialization: + write-dates-as-timestamps: true + +rocketmq: + name-server: 139.9.154.68:9876 + producer: + access-key: huifukeji + secret-key: HF123456. + #必须指定group + group: default-group + consumer: + access-key: huifukeji + secret-key: HF123456. - #配置日期返回至前台为时间戳 - jackson: - serialization: - write-dates-as-timestamps: true +jetcache: + statIntervalMinutes: 15 + areaInCacheName: false + local: + default: + type: linkedhashmap + keyConvertor: fastjson + remote: + default: + type: redis + host: 139.9.154.68 + port: 36379 + password: HF123456.Redis + database: 2 + keyConvertor: fastjson + broadcastChannel: projectA + valueEncoder: java + valueDecoder: java + poolConfig: + minIdle: 5 + maxIdle: 20 + maxTotal: 50 - mybatis: - mapperLocations: - - classpath*:sqlmap*/*.xml - type-aliases-package: - org.springboot.sample.entity +mybatis: + mapperLocations: + - classpath*:sqlmap*/*.xml + type-aliases-package: + org.springboot.sample.entity - pagehelper: - helperDialect: mysql - reasonable: true - supportMethodsArguments: true - params: count=countSql +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql diff --git a/service/src/main/java/com/hfkj/config/SpPrinterTemplate.java b/service/src/main/java/com/hfkj/config/SpPrinterTemplate.java index f5c3f88..6f24d3b 100644 --- a/service/src/main/java/com/hfkj/config/SpPrinterTemplate.java +++ b/service/src/main/java/com/hfkj/config/SpPrinterTemplate.java @@ -69,7 +69,7 @@ public class SpPrinterTemplate { Map receiptMap, boolean makeUp) throws Exception { - String str = "" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptTop"))?MapUtils.getString(receiptMap, "receiptTop"):"嗨森逛") + "
" + + String str = "" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptTop"))?MapUtils.getString(receiptMap, "receiptTop"):"嗨加油") + "
" + "" + gasName + (makeUp?"(补打)":"") + "
" + "(收银员存根)
" + "------------------------------
" + @@ -78,7 +78,7 @@ public class SpPrinterTemplate { "打印时间:" + DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + "
" + "支付时间:" + payTime + "
" + "电话:" + (StringUtils.isNotBlank(phone)?phone.substring(0, 3) + "****" + phone.substring(7):"") + "
" + - "来源:" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptSource"))?MapUtils.getString(receiptMap, "receiptSource"):"嗨森逛")+ "
" + + "来源:" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptSource"))?MapUtils.getString(receiptMap, "receiptSource"):"嗨加油")+ "
" + "油枪:"+ gunNo + "号
" + "油品:" + oilNo + "#
" + "升数:" + oilLiters +"升
" + @@ -87,7 +87,7 @@ public class SpPrinterTemplate { "加油金额
" + "¥" + orderPrice + "元
" + "------------------------------
" + - ""+ (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptBottom"))?MapUtils.getString(receiptMap, "receiptBottom"):"开心又省钱; 来"嗨森逛"") + ""; + ""+ (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptBottom"))?MapUtils.getString(receiptMap, "receiptBottom"):"开心又省钱; 来"嗨加油"") + ""; return str; } @@ -114,7 +114,7 @@ public class SpPrinterTemplate { String orderPrice, Map receiptMap, boolean makeUp) throws Exception { - String str = "" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptTop"))?MapUtils.getString(receiptMap, "receiptTop"):"嗨森逛") + "
" + + String str = "" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptTop"))?MapUtils.getString(receiptMap, "receiptTop"):"嗨加油") + "
" + "" + gasName + (makeUp?"(补打)":"") + "
" + "(客户存根)
" + "------------------------------
" + @@ -123,7 +123,7 @@ public class SpPrinterTemplate { "打印时间:" + DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + "
" + "支付时间:" + payTime + "
" + "电话:" + (StringUtils.isNotBlank(phone)?phone.substring(0, 3) + "****" + phone.substring(7):"") + "
" + - "来源:" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptSource"))?MapUtils.getString(receiptMap, "receiptSource"):"嗨森逛")+ "
" + + "来源:" + (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptSource"))?MapUtils.getString(receiptMap, "receiptSource"):"嗨加油")+ "
" + "油枪:"+ gunNo + "号
" + "油品:" + oilNo + "#
" + "升数:" + oilLiters +"升
" + @@ -132,7 +132,7 @@ public class SpPrinterTemplate { "加油金额
" + "¥" + orderPrice + "元
" + "------------------------------
" + - ""+ (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptBottom"))?MapUtils.getString(receiptMap, "receiptBottom"):"开心又省钱; 来"嗨森逛"") + ""; + ""+ (StringUtils.isNotBlank(MapUtils.getString(receiptMap, "receiptBottom"))?MapUtils.getString(receiptMap, "receiptBottom"):"开心又省钱; 来"嗨加油"") + ""; return str; } diff --git a/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java b/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java index cedfc56..fd63acd 100644 --- a/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java @@ -47,7 +47,7 @@ public interface BsGasClassGroupTaskMapperExt { " COUNT(1) refuelNum," + " case when SUM(a.gas_oil_liters) is not null then SUM(a.gas_oil_liters) else 0 end refuelLiters" + " from bs_gas_order a" + - " where a.gas_class_group_task_id = #{gasClassGroupTaskId} and a.status in (4)" + + " where a.gas_class_group_task_id = #{gasClassGroupTaskId} and a.status in (2)" + " GROUP BY a.gas_oil_no) b on b.gas_oil_no = a.oil_no" + " WHERE a.mer_id = #{gasId} and 0 ]]> " + "") diff --git a/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java b/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java index a1b196f..1723bca 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderRefundMapper.java @@ -44,7 +44,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { "user_id, user_phone, ", "refund_order_no, account_merchant_no, ", "account_merchant_key, refund_pay_channel, ", - "reufnd_pay_type, refund_serial_no, ", + "refund_pay_type, refund_serial_no, ", "refund_pay_channel_order_no, refund_price, ", "refund_integral, refund_remark, ", "refund_status, refund_fail_reason, ", @@ -57,7 +57,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { "#{userId,jdbcType=BIGINT}, #{userPhone,jdbcType=VARCHAR}, ", "#{refundOrderNo,jdbcType=VARCHAR}, #{accountMerchantNo,jdbcType=VARCHAR}, ", "#{accountMerchantKey,jdbcType=VARCHAR}, #{refundPayChannel,jdbcType=INTEGER}, ", - "#{reufndPayType,jdbcType=INTEGER}, #{refundSerialNo,jdbcType=VARCHAR}, ", + "#{refundPayType,jdbcType=INTEGER}, #{refundSerialNo,jdbcType=VARCHAR}, ", "#{refundPayChannelOrderNo,jdbcType=VARCHAR}, #{refundPrice,jdbcType=DECIMAL}, ", "#{refundIntegral,jdbcType=BIGINT}, #{refundRemark,jdbcType=VARCHAR}, ", "#{refundStatus,jdbcType=INTEGER}, #{refundFailReason,jdbcType=VARCHAR}, ", @@ -86,7 +86,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { @Result(column="account_merchant_no", property="accountMerchantNo", jdbcType=JdbcType.VARCHAR), @Result(column="account_merchant_key", property="accountMerchantKey", jdbcType=JdbcType.VARCHAR), @Result(column="refund_pay_channel", property="refundPayChannel", jdbcType=JdbcType.INTEGER), - @Result(column="reufnd_pay_type", property="reufndPayType", jdbcType=JdbcType.INTEGER), + @Result(column="refund_pay_type", property="refundPayType", jdbcType=JdbcType.INTEGER), @Result(column="refund_serial_no", property="refundSerialNo", jdbcType=JdbcType.VARCHAR), @Result(column="refund_pay_channel_order_no", property="refundPayChannelOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL), @@ -109,7 +109,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { @Select({ "select", "id, mer_id, mer_no, order_no, order_child_no, user_id, user_phone, refund_order_no, ", - "account_merchant_no, account_merchant_key, refund_pay_channel, reufnd_pay_type, ", + "account_merchant_no, account_merchant_key, refund_pay_channel, refund_pay_type, ", "refund_serial_no, refund_pay_channel_order_no, refund_price, refund_integral, ", "refund_remark, refund_status, refund_fail_reason, create_time, update_time, ", "finish_time, op_user_type, op_user_id, op_user_name, ext_1, ext_2, ext_3", @@ -128,7 +128,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { @Result(column="account_merchant_no", property="accountMerchantNo", jdbcType=JdbcType.VARCHAR), @Result(column="account_merchant_key", property="accountMerchantKey", jdbcType=JdbcType.VARCHAR), @Result(column="refund_pay_channel", property="refundPayChannel", jdbcType=JdbcType.INTEGER), - @Result(column="reufnd_pay_type", property="reufndPayType", jdbcType=JdbcType.INTEGER), + @Result(column="refund_pay_type", property="refundPayType", jdbcType=JdbcType.INTEGER), @Result(column="refund_serial_no", property="refundSerialNo", jdbcType=JdbcType.VARCHAR), @Result(column="refund_pay_channel_order_no", property="refundPayChannelOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="refund_price", property="refundPrice", jdbcType=JdbcType.DECIMAL), @@ -169,7 +169,7 @@ public interface BsOrderRefundMapper extends BsOrderRefundMapperExt { "account_merchant_no = #{accountMerchantNo,jdbcType=VARCHAR},", "account_merchant_key = #{accountMerchantKey,jdbcType=VARCHAR},", "refund_pay_channel = #{refundPayChannel,jdbcType=INTEGER},", - "reufnd_pay_type = #{reufndPayType,jdbcType=INTEGER},", + "refund_pay_type = #{refundPayType,jdbcType=INTEGER},", "refund_serial_no = #{refundSerialNo,jdbcType=VARCHAR},", "refund_pay_channel_order_no = #{refundPayChannelOrderNo,jdbcType=VARCHAR},", "refund_price = #{refundPrice,jdbcType=DECIMAL},", diff --git a/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java index f3d70cd..52dd36a 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderRefundSqlProvider.java @@ -68,8 +68,8 @@ public class BsOrderRefundSqlProvider { sql.VALUES("refund_pay_channel", "#{refundPayChannel,jdbcType=INTEGER}"); } - if (record.getReufndPayType() != null) { - sql.VALUES("reufnd_pay_type", "#{reufndPayType,jdbcType=INTEGER}"); + if (record.getRefundPayType() != null) { + sql.VALUES("refund_pay_type", "#{refundPayType,jdbcType=INTEGER}"); } if (record.getRefundSerialNo() != null) { @@ -156,7 +156,7 @@ public class BsOrderRefundSqlProvider { sql.SELECT("account_merchant_no"); sql.SELECT("account_merchant_key"); sql.SELECT("refund_pay_channel"); - sql.SELECT("reufnd_pay_type"); + sql.SELECT("refund_pay_type"); sql.SELECT("refund_serial_no"); sql.SELECT("refund_pay_channel_order_no"); sql.SELECT("refund_price"); @@ -234,8 +234,8 @@ public class BsOrderRefundSqlProvider { sql.SET("refund_pay_channel = #{record.refundPayChannel,jdbcType=INTEGER}"); } - if (record.getReufndPayType() != null) { - sql.SET("reufnd_pay_type = #{record.reufndPayType,jdbcType=INTEGER}"); + if (record.getRefundPayType() != null) { + sql.SET("refund_pay_type = #{record.refundPayType,jdbcType=INTEGER}"); } if (record.getRefundSerialNo() != null) { @@ -321,7 +321,7 @@ public class BsOrderRefundSqlProvider { sql.SET("account_merchant_no = #{record.accountMerchantNo,jdbcType=VARCHAR}"); sql.SET("account_merchant_key = #{record.accountMerchantKey,jdbcType=VARCHAR}"); sql.SET("refund_pay_channel = #{record.refundPayChannel,jdbcType=INTEGER}"); - sql.SET("reufnd_pay_type = #{record.reufndPayType,jdbcType=INTEGER}"); + sql.SET("refund_pay_type = #{record.refundPayType,jdbcType=INTEGER}"); sql.SET("refund_serial_no = #{record.refundSerialNo,jdbcType=VARCHAR}"); sql.SET("refund_pay_channel_order_no = #{record.refundPayChannelOrderNo,jdbcType=VARCHAR}"); sql.SET("refund_price = #{record.refundPrice,jdbcType=DECIMAL}"); @@ -388,8 +388,8 @@ public class BsOrderRefundSqlProvider { sql.SET("refund_pay_channel = #{refundPayChannel,jdbcType=INTEGER}"); } - if (record.getReufndPayType() != null) { - sql.SET("reufnd_pay_type = #{reufndPayType,jdbcType=INTEGER}"); + if (record.getRefundPayType() != null) { + sql.SET("refund_pay_type = #{refundPayType,jdbcType=INTEGER}"); } if (record.getRefundSerialNo() != null) { diff --git a/service/src/main/java/com/hfkj/entity/BsOrderRefund.java b/service/src/main/java/com/hfkj/entity/BsOrderRefund.java index c401eae..d8c1ac3 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderRefund.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderRefund.java @@ -72,7 +72,7 @@ public class BsOrderRefund implements Serializable { /** * 支付类型 数据字典:ORDER_PAY_TYPE */ - private Integer reufndPayType; + private Integer refundPayType; /** * 客户退款流水号 @@ -238,12 +238,12 @@ public class BsOrderRefund implements Serializable { this.refundPayChannel = refundPayChannel; } - public Integer getReufndPayType() { - return reufndPayType; + public Integer getRefundPayType() { + return refundPayType; } - public void setReufndPayType(Integer reufndPayType) { - this.reufndPayType = reufndPayType; + public void setRefundPayType(Integer refundPayType) { + this.refundPayType = refundPayType; } public String getRefundSerialNo() { @@ -397,7 +397,7 @@ public class BsOrderRefund implements Serializable { && (this.getAccountMerchantNo() == null ? other.getAccountMerchantNo() == null : this.getAccountMerchantNo().equals(other.getAccountMerchantNo())) && (this.getAccountMerchantKey() == null ? other.getAccountMerchantKey() == null : this.getAccountMerchantKey().equals(other.getAccountMerchantKey())) && (this.getRefundPayChannel() == null ? other.getRefundPayChannel() == null : this.getRefundPayChannel().equals(other.getRefundPayChannel())) - && (this.getReufndPayType() == null ? other.getReufndPayType() == null : this.getReufndPayType().equals(other.getReufndPayType())) + && (this.getRefundPayType() == null ? other.getRefundPayType() == null : this.getRefundPayType().equals(other.getRefundPayType())) && (this.getRefundSerialNo() == null ? other.getRefundSerialNo() == null : this.getRefundSerialNo().equals(other.getRefundSerialNo())) && (this.getRefundPayChannelOrderNo() == null ? other.getRefundPayChannelOrderNo() == null : this.getRefundPayChannelOrderNo().equals(other.getRefundPayChannelOrderNo())) && (this.getRefundPrice() == null ? other.getRefundPrice() == null : this.getRefundPrice().equals(other.getRefundPrice())) @@ -431,7 +431,7 @@ public class BsOrderRefund implements Serializable { result = prime * result + ((getAccountMerchantNo() == null) ? 0 : getAccountMerchantNo().hashCode()); result = prime * result + ((getAccountMerchantKey() == null) ? 0 : getAccountMerchantKey().hashCode()); result = prime * result + ((getRefundPayChannel() == null) ? 0 : getRefundPayChannel().hashCode()); - result = prime * result + ((getReufndPayType() == null) ? 0 : getReufndPayType().hashCode()); + result = prime * result + ((getRefundPayType() == null) ? 0 : getRefundPayType().hashCode()); result = prime * result + ((getRefundSerialNo() == null) ? 0 : getRefundSerialNo().hashCode()); result = prime * result + ((getRefundPayChannelOrderNo() == null) ? 0 : getRefundPayChannelOrderNo().hashCode()); result = prime * result + ((getRefundPrice() == null) ? 0 : getRefundPrice().hashCode()); @@ -468,7 +468,7 @@ public class BsOrderRefund implements Serializable { sb.append(", accountMerchantNo=").append(accountMerchantNo); sb.append(", accountMerchantKey=").append(accountMerchantKey); sb.append(", refundPayChannel=").append(refundPayChannel); - sb.append(", reufndPayType=").append(reufndPayType); + sb.append(", refundPayType=").append(refundPayType); sb.append(", refundSerialNo=").append(refundSerialNo); sb.append(", refundPayChannelOrderNo=").append(refundPayChannelOrderNo); sb.append(", refundPrice=").append(refundPrice); diff --git a/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java b/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java index d474160..c37ef77 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderRefundExample.java @@ -856,63 +856,63 @@ public class BsOrderRefundExample { return (Criteria) this; } - public Criteria andReufndPayTypeIsNull() { - addCriterion("reufnd_pay_type is null"); + public Criteria andRefundPayTypeIsNull() { + addCriterion("refund_pay_type is null"); return (Criteria) this; } - public Criteria andReufndPayTypeIsNotNull() { - addCriterion("reufnd_pay_type is not null"); + public Criteria andRefundPayTypeIsNotNull() { + addCriterion("refund_pay_type is not null"); return (Criteria) this; } - public Criteria andReufndPayTypeEqualTo(Integer value) { - addCriterion("reufnd_pay_type =", value, "reufndPayType"); + public Criteria andRefundPayTypeEqualTo(Integer value) { + addCriterion("refund_pay_type =", value, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeNotEqualTo(Integer value) { - addCriterion("reufnd_pay_type <>", value, "reufndPayType"); + public Criteria andRefundPayTypeNotEqualTo(Integer value) { + addCriterion("refund_pay_type <>", value, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeGreaterThan(Integer value) { - addCriterion("reufnd_pay_type >", value, "reufndPayType"); + public Criteria andRefundPayTypeGreaterThan(Integer value) { + addCriterion("refund_pay_type >", value, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeGreaterThanOrEqualTo(Integer value) { - addCriterion("reufnd_pay_type >=", value, "reufndPayType"); + public Criteria andRefundPayTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("refund_pay_type >=", value, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeLessThan(Integer value) { - addCriterion("reufnd_pay_type <", value, "reufndPayType"); + public Criteria andRefundPayTypeLessThan(Integer value) { + addCriterion("refund_pay_type <", value, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeLessThanOrEqualTo(Integer value) { - addCriterion("reufnd_pay_type <=", value, "reufndPayType"); + public Criteria andRefundPayTypeLessThanOrEqualTo(Integer value) { + addCriterion("refund_pay_type <=", value, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeIn(List values) { - addCriterion("reufnd_pay_type in", values, "reufndPayType"); + public Criteria andRefundPayTypeIn(List values) { + addCriterion("refund_pay_type in", values, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeNotIn(List values) { - addCriterion("reufnd_pay_type not in", values, "reufndPayType"); + public Criteria andRefundPayTypeNotIn(List values) { + addCriterion("refund_pay_type not in", values, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeBetween(Integer value1, Integer value2) { - addCriterion("reufnd_pay_type between", value1, value2, "reufndPayType"); + public Criteria andRefundPayTypeBetween(Integer value1, Integer value2) { + addCriterion("refund_pay_type between", value1, value2, "refundPayType"); return (Criteria) this; } - public Criteria andReufndPayTypeNotBetween(Integer value1, Integer value2) { - addCriterion("reufnd_pay_type not between", value1, value2, "reufndPayType"); + public Criteria andRefundPayTypeNotBetween(Integer value1, Integer value2) { + addCriterion("refund_pay_type not between", value1, value2, "refundPayType"); return (Criteria) this; } diff --git a/service/src/main/java/com/hfkj/service/gas/BsGasStaffService.java b/service/src/main/java/com/hfkj/service/gas/BsGasStaffService.java index 252d3ab..fb4a6c3 100644 --- a/service/src/main/java/com/hfkj/service/gas/BsGasStaffService.java +++ b/service/src/main/java/com/hfkj/service/gas/BsGasStaffService.java @@ -35,6 +35,18 @@ public interface BsGasStaffService { */ void delStaff(Long id); + /** + * 禁用员工账户 + * @param id + */ + void disabled(Long id); + + /** + * 恢复员工账户 + * @param id + */ + void recover(Long id); + /** * 根据id查询 * @param id diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOilGunNoServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOilGunNoServiceImpl.java index c2e429d..b14e725 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasOilGunNoServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasOilGunNoServiceImpl.java @@ -86,7 +86,7 @@ public class BsGasOilGunNoServiceImpl implements BsGasOilGunNoService { @Override public BsGasOilGunNo getDetail(String merNo, String oilNo, String gunNo) { BsGasOilGunNoExample example = new BsGasOilGunNoExample(); - example.createCriteria().andMerNoEqualTo(merNo).andOilNoEqualTo(oilNo).andGunNoEqualTo(gunNo).andStatusEqualTo(1); + example.createCriteria().andMerNoEqualTo(merNo).andOilNoEqualTo(oilNo).andGunNoEqualTo(gunNo).andStatusNotEqualTo(0); List list = gasOilGunNoMapper.selectByExample(example); if (!list.isEmpty()) { return list.get(0); diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java index 7a26d9c..edf1060 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java @@ -18,6 +18,7 @@ import com.hfkj.service.gas.BsGasOilPriceService; import com.hfkj.service.gas.BsGasService; import com.hfkj.service.BsMerchantService; import com.hfkj.sysenum.agent.AgentPriceTypeEnum; +import com.hfkj.sysenum.gas.GasOilPriceStatusEnum; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -164,12 +165,14 @@ public class BsGasServiceImpl implements BsGasService { List oilNoModelList = new ArrayList<>(); for (BsGasOilPrice gasOilPrice : oilNoList) { - GasOilPriceModel oilNo = new GasOilPriceModel(); - BeanUtils.copyProperties(gasOilPrice, oilNo); - // 查询抢号 - oilNo.setGasOilGunNo(gasOilGunNoService.getOilGunNoList(merNo, gasOilPrice.getOilNo())); + if (gasOilPrice.getStatus().equals(GasOilPriceStatusEnum.status1.getNumber())) { + GasOilPriceModel oilNo = new GasOilPriceModel(); + BeanUtils.copyProperties(gasOilPrice, oilNo); + // 查询抢号 + oilNo.setGasOilGunNo(gasOilGunNoService.getOilGunNoList(merNo, gasOilPrice.getOilNo())); - oilNoModelList.add(oilNo); + oilNoModelList.add(oilNo); + } } gasModel.setGasOilPrice(oilNoModelList); // 存入缓存 diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasStaffServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasStaffServiceImpl.java index bb89f00..ce092cf 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasStaffServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasStaffServiceImpl.java @@ -15,6 +15,7 @@ import com.hfkj.service.BsMerchantService; import com.hfkj.service.gas.BsGasStaffService; import com.hfkj.service.sec.SecUserService; import com.hfkj.sysenum.SecUserObjectTypeEnum; +import com.hfkj.sysenum.SecUserStatusEnum; import com.hfkj.sysenum.gas.GasStaffStatus; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -136,6 +137,40 @@ public class BsGasStaffServiceImpl implements BsGasStaffService { userService.editUser(account); } + @Override + public void disabled(Long id) { + // 查询油站员工 + BsGasStaff gasStaff = getStaffDetailById(id); + if (gasStaff == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工"); + } + gasStaff.setStatus(GasStaffStatus.status2.getStatus()); + editData(gasStaff); + + SecUser secUser = userService.getDetail(SecUserObjectTypeEnum.type3, gasStaff.getId()); + if (secUser != null) { + secUser.setStatus(SecUserStatusEnum.status2.getCode()); + userService.editUser(secUser); + } + } + + @Override + public void recover(Long id) { + // 查询油站员工 + BsGasStaff gasStaff = getStaffDetailById(id); + if (gasStaff == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到员工"); + } + gasStaff.setStatus(GasStaffStatus.status1.getStatus()); + editData(gasStaff); + + SecUser secUser = userService.getDetail(SecUserObjectTypeEnum.type3, gasStaff.getId()); + if (secUser != null) { + secUser.setStatus(SecUserStatusEnum.status1.getCode()); + userService.editUser(secUser); + } + } + @Override public BsGasStaff getStaffDetailById(Long id) { return gasStaffMapper.selectByPrimaryKey(id); diff --git a/service/src/main/java/com/hfkj/service/impl/BsDeviceServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsDeviceServiceImpl.java index 85f3df3..7093a78 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsDeviceServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsDeviceServiceImpl.java @@ -101,7 +101,7 @@ public class BsDeviceServiceImpl implements BsDeviceService { gasOrder.getGasOilLiters().toString(), gasOrder.getGasRefuelPrice().toString(), receiptMap, - false + makeUp ), 1); sp.print(device.getDeviceSn(), @@ -115,7 +115,7 @@ public class BsDeviceServiceImpl implements BsDeviceService { gasOrder.getGasOilLiters().toString(), gasOrder.getGasRefuelPrice().toString(), receiptMap, - false + makeUp ), 1); } catch (Exception e) { diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderSettleService.java b/service/src/main/java/com/hfkj/service/order/BsOrderSettleService.java new file mode 100644 index 0000000..66cbbb8 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/BsOrderSettleService.java @@ -0,0 +1,24 @@ +package com.hfkj.service.order; + +import com.hfkj.entity.BsOrderSettle; + +/** + * @className: BsOrderSettleService + * @author: HuRui + * @date: 2024/6/24 + **/ +public interface BsOrderSettleService { + + /** + * 编辑数据 + * @param data + */ + void editData(BsOrderSettle data); + + /** + * 查询数据 + * @param orderNo + * @return + */ + BsOrderSettle getData(String orderNo); +} diff --git a/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java new file mode 100644 index 0000000..7e8fd23 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java @@ -0,0 +1,41 @@ +package com.hfkj.service.order; + +import com.hfkj.entity.BsGasOrder; +import com.hfkj.entity.BsOrderChild; +import com.hfkj.entity.BsOrderRefund; +import com.hfkj.model.order.OrderChildModel; +import com.hfkj.service.gas.BsGasOrderService; +import com.hfkj.sysenum.gas.OrderOilStatus; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 退款业务 + * @className: OrderRefundService + * @author: HuRui + * @date: 2024/6/24 + **/ +@Component +public class OrderRefundBusiness { + + @Resource + private BsGasOrderService gasOrderService; + + /** + * 加油订单业务 + * @param refund + */ + public void gasOrder(BsOrderRefund refund) { + // 查询加油订单 + BsGasOrder gasOrder = gasOrderService.getDetailByOrderNo(refund.getOrderNo()); + if (gasOrder != null) { + gasOrder.setStatus(OrderOilStatus.STATUS4.getNumber()); + gasOrder.setRefundTime(refund.getFinishTime()); + gasOrder.setRefundRemarks(refund.getRefundRemark()); + gasOrderService.updateGasOrder(gasOrder); + } + } + +} diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java index e6cf219..421b753 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java @@ -8,17 +8,12 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.RandomUtils; import com.hfkj.dao.BsOrderRefundMapper; -import com.hfkj.entity.BsMerchant; -import com.hfkj.entity.BsOrder; -import com.hfkj.entity.BsOrderRefund; -import com.hfkj.entity.BsOrderRefundExample; +import com.hfkj.entity.*; import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderModel; import com.hfkj.pay.HuiPayService; import com.hfkj.service.BsMerchantService; -import com.hfkj.service.order.BsOrderChildService; -import com.hfkj.service.order.BsOrderRefundService; -import com.hfkj.service.order.BsOrderService; +import com.hfkj.service.order.*; import com.hfkj.sysenum.order.OrderChildStatusEnum; import com.hfkj.sysenum.order.OrderPayChannelEnum; import com.hfkj.sysenum.order.OrderRefundStatusEnum; @@ -53,6 +48,11 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { private BsOrderChildService orderChildService; @Resource private BsMerchantService merchantService; + @Resource + private BsOrderSettleService orderSettleService; + @Resource + private OrderRefundBusiness OrderRefundBusiness; + @Override public void editData(BsOrderRefund data) { data.setUpdateTime(new Date()); @@ -85,12 +85,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { editData(orderRefund); } - }/* else if (OrderPayChannelEnum.type2.getCode() == orderRefund.getRefundPayChannel()) { - // TODO 暂无该支付方式 - - } else if (OrderPayChannelEnum.type3.getCode() ==orderRefund.getRefundPayChannel()) { - // TODO 暂无该支付方式 - }*/ else { + } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!该支付方式暂不支持退款"); } } catch (BaseException e) { @@ -112,16 +107,19 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { // 查询交易订单 OrderModel order = orderService.getDetail(orderNo); if (order == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "该账户已被禁用,无法进行交易"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单"); } if (!order.getOrderStatus().equals(OrderStatusEnum.status2.getCode())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "该账户已被禁用,无法进行交易"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单交易状态错误"); } boolean refundSuccess = true; for (OrderChildModel orderChild : order.getOrderChildList()) { try { - tradeOrderChildRefund(orderChild.getChildOrderNo(), orderChild.getProductCount(), remark); + BsOrderRefund orderRefund = tradeOrderChildRefund(orderChild.getChildOrderNo(), orderChild.getProductCount(), remark); + if (orderRefund.getRefundStatus().equals(OrderRefundStatusEnum.status3.getCode())) { + refundSuccess = false; + } } catch (Exception e) { refundSuccess = false; } @@ -131,6 +129,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { orderService.editData(order); // 删除缓存 orderService.cacheDelete(order.getOrderNo()); + return order; } @@ -150,6 +149,11 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { if (order == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的交易订单"); } + // 查询交易结算 + BsOrderSettle orderSettle = orderSettleService.getData(order.getOrderNo()); + if (orderSettle == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的交易结算"); + } // 查询商户 BsMerchant merchant = merchantService.getMerchant(orderChild.getMerNo()); if (merchant == null) { @@ -166,7 +170,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { // 退款订单号 退款标识:R + 时间 + 随机3位数字 orderRefund.setRefundOrderNo("R"+ DateUtil.date2String(new Date(), "yyMMddHHmmss") + RandomUtils.number(3, false)); orderRefund.setRefundPayChannel(order.getPayChannel()); - orderRefund.setReufndPayType(order.getPayType()); + orderRefund.setRefundPayType(order.getPayType()); if (orderChild.getSurplusRefundCount().equals(productCount)) { // 全部退款 @@ -202,8 +206,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { orderRefund.setRefundRemark(remark); orderRefund.setRefundStatus(OrderRefundStatusEnum.status1.getCode()); - orderRefund.setAccountMerchantNo(orderChild.getSettleAccount()); - orderRefund.setAccountMerchantKey(orderChild.getSettleAccountKey()); + orderRefund.setAccountMerchantNo(orderSettle.getSettleMerNo()); + orderRefund.setAccountMerchantKey(orderSettle.getSettleMerKey()); editData(orderRefund); // 资金退款 @@ -220,6 +224,9 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService { orderChildService.editData(orderChild); } + // 处理退款业务 + OrderRefundBusiness.gasOrder(orderRefund); + // 删除缓存 orderService.cacheDelete(order.getOrderNo()); return orderRefund; 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 aaf162b..ea6812a 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 @@ -360,6 +360,7 @@ public class BsOrderServiceImpl implements BsOrderService { childOrder.setStatus(OrderChildStatusEnum.status2.getCode()); orderChildService.editData(childOrder); } + cache(order); // 处理业务 orderPaySuccessService.orderBusHandle(order); } diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderSettleServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderSettleServiceImpl.java new file mode 100644 index 0000000..edd8a37 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderSettleServiceImpl.java @@ -0,0 +1,44 @@ +package com.hfkj.service.order.impl; + +import com.hfkj.dao.BsOrderSettleMapper; +import com.hfkj.entity.BsOrderSettle; +import com.hfkj.entity.BsOrderSettleExample; +import com.hfkj.service.order.BsOrderSettleService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * @className: BsOrderSettleServiceImpl + * @author: HuRui + * @date: 2024/6/24 + **/ +@Service("BsOrderSettleService") +public class BsOrderSettleServiceImpl implements BsOrderSettleService { + @Resource + private BsOrderSettleMapper orderSettleMapper; + + @Override + public void editData(BsOrderSettle data) { + data.setUpdateTime(new Date()); + if (data.getId() == null) { + data.setCreateTime(new Date()); + orderSettleMapper.insert(data); + } else { + orderSettleMapper.updateByPrimaryKey(data); + } + } + + @Override + public BsOrderSettle getData(String orderNo) { + BsOrderSettleExample example = new BsOrderSettleExample(); + example.createCriteria().andOrderNoEqualTo(orderNo); + List list = orderSettleMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } +}