diff --git a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java index 818069c6..3c9865a0 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/LoginController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/LoginController.java @@ -239,7 +239,7 @@ public class LoginController { String aesStr = AESEncodeUtil.aesEncrypt(secUser.getId().toString()); userInfoModel.setToken(aesStr); SessionObject so = new SessionObject(aesStr, secUser.getObjectType(), userInfoModel); - userCenter.save(null,null,so); + userCenter.save(request,response,so); return ResponseMsgUtil.success(so); } catch (Exception e) { log.error("login error!",e); diff --git a/hai-order/src/main/java/com/web/controller/business/OrderOilController.java b/hai-order/src/main/java/com/web/controller/business/OrderOilController.java index eee3ec02..07418301 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderOilController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderOilController.java @@ -160,6 +160,20 @@ public class OrderOilController { } + @RequestMapping(value="/getOrderByOrderNo",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据订单号查询") + public ResponseData getOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { + try { + + return ResponseMsgUtil.success(gasOrderService.getDetailByOrderNo(orderNo)); + + } catch (Exception e) { + log.error("HighGasOrderController -> getOrderByOrderNo() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getOilOrderDetail",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询油站详情") @@ -293,9 +307,11 @@ public class OrderOilController { model.setGasPricePlatform(gasOrder.getGasPricePlatform()); model.setGasPriceGun(gasOrder.getGasPriceGun()); model.setGasPriceOfficial(gasOrder.getGasPriceOfficial()); - model.setDeductionPrice(gasOrder.getTotalDeductionPrice()); + model.setTotalDeductionPrice(gasOrder.getTotalDeductionPrice()); + model.setDeductionCouponPrice(gasOrder.getDeductionCouponPrice()); + model.setDeductionProductPrice(gasOrder.getDeductionProductPrice()); model.setPayablePrice(gasOrder.getPayablePrice()); - model.setPayGold(gasOrder.getPayGold()); + model.setPayGold(gasOrder.getPayGold()/100); model.setPayPrice(gasOrder.getPayPrice()!=null?gasOrder.getPayPrice().toString():"未支付"); model.setStatus(OrderOilStatus.getNameByType(gasOrder.getStatus())); model.setCreateTime(gasOrder.getCreateTime()); @@ -329,7 +345,9 @@ public class OrderOilController { includeColumnFiledNames.add("gasPricePlatform"); includeColumnFiledNames.add("gasPriceGun"); includeColumnFiledNames.add("gasPriceOfficial"); - includeColumnFiledNames.add("deductionPrice"); + includeColumnFiledNames.add("totalDeductionPrice"); + includeColumnFiledNames.add("deductionCouponPrice"); + includeColumnFiledNames.add("deductionProductPrice"); includeColumnFiledNames.add("payablePrice"); includeColumnFiledNames.add("payGold"); includeColumnFiledNames.add("payPrice"); diff --git a/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java index 52696ad7..ddf77574 100644 --- a/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogMapper.java @@ -40,12 +40,14 @@ public interface HighUserLoginLogMapper extends HighUserLoginLogMapperExt { @Insert({ "insert into high_user_login_log (user_id, user_phone, ", - "platform, ip, province_name, ", + "platform_code, platform_name, ", + "ip, province_name, ", "city_code, city_name, ", "`status`, create_time, ", "ext_1, ext_2, ext_3)", "values (#{userId,jdbcType=BIGINT}, #{userPhone,jdbcType=VARCHAR}, ", - "#{platform,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, ", + "#{platformCode,jdbcType=VARCHAR}, #{platformName,jdbcType=VARCHAR}, ", + "#{ip,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, ", "#{cityCode,jdbcType=VARCHAR}, #{cityName,jdbcType=VARCHAR}, ", "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" @@ -62,7 +64,8 @@ public interface HighUserLoginLogMapper extends HighUserLoginLogMapperExt { @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), - @Result(column="platform", property="platform", jdbcType=JdbcType.VARCHAR), + @Result(column="platform_code", property="platformCode", jdbcType=JdbcType.VARCHAR), + @Result(column="platform_name", property="platformName", jdbcType=JdbcType.VARCHAR), @Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), @Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR), @Result(column="city_code", property="cityCode", jdbcType=JdbcType.VARCHAR), @@ -77,8 +80,8 @@ public interface HighUserLoginLogMapper extends HighUserLoginLogMapperExt { @Select({ "select", - "id, user_id, user_phone, platform, ip, province_name, city_code, city_name, ", - "`status`, create_time, ext_1, ext_2, ext_3", + "id, user_id, user_phone, platform_code, platform_name, ip, province_name, city_code, ", + "city_name, `status`, create_time, ext_1, ext_2, ext_3", "from high_user_login_log", "where id = #{id,jdbcType=BIGINT}" }) @@ -86,7 +89,8 @@ public interface HighUserLoginLogMapper extends HighUserLoginLogMapperExt { @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="user_phone", property="userPhone", jdbcType=JdbcType.VARCHAR), - @Result(column="platform", property="platform", jdbcType=JdbcType.VARCHAR), + @Result(column="platform_code", property="platformCode", jdbcType=JdbcType.VARCHAR), + @Result(column="platform_name", property="platformName", jdbcType=JdbcType.VARCHAR), @Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), @Result(column="province_name", property="provinceName", jdbcType=JdbcType.VARCHAR), @Result(column="city_code", property="cityCode", jdbcType=JdbcType.VARCHAR), @@ -112,7 +116,8 @@ public interface HighUserLoginLogMapper extends HighUserLoginLogMapperExt { "update high_user_login_log", "set user_id = #{userId,jdbcType=BIGINT},", "user_phone = #{userPhone,jdbcType=VARCHAR},", - "platform = #{platform,jdbcType=VARCHAR},", + "platform_code = #{platformCode,jdbcType=VARCHAR},", + "platform_name = #{platformName,jdbcType=VARCHAR},", "ip = #{ip,jdbcType=VARCHAR},", "province_name = #{provinceName,jdbcType=VARCHAR},", "city_code = #{cityCode,jdbcType=VARCHAR},", diff --git a/hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java index e9c8f1f1..1f987f1b 100644 --- a/hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighUserLoginLogSqlProvider.java @@ -36,8 +36,12 @@ public class HighUserLoginLogSqlProvider { sql.VALUES("user_phone", "#{userPhone,jdbcType=VARCHAR}"); } - if (record.getPlatform() != null) { - sql.VALUES("platform", "#{platform,jdbcType=VARCHAR}"); + if (record.getPlatformCode() != null) { + sql.VALUES("platform_code", "#{platformCode,jdbcType=VARCHAR}"); + } + + if (record.getPlatformName() != null) { + sql.VALUES("platform_name", "#{platformName,jdbcType=VARCHAR}"); } if (record.getIp() != null) { @@ -88,7 +92,8 @@ public class HighUserLoginLogSqlProvider { } sql.SELECT("user_id"); sql.SELECT("user_phone"); - sql.SELECT("platform"); + sql.SELECT("platform_code"); + sql.SELECT("platform_name"); sql.SELECT("ip"); sql.SELECT("province_name"); sql.SELECT("city_code"); @@ -127,8 +132,12 @@ public class HighUserLoginLogSqlProvider { sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); } - if (record.getPlatform() != null) { - sql.SET("platform = #{record.platform,jdbcType=VARCHAR}"); + if (record.getPlatformCode() != null) { + sql.SET("platform_code = #{record.platformCode,jdbcType=VARCHAR}"); + } + + if (record.getPlatformName() != null) { + sql.SET("platform_name = #{record.platformName,jdbcType=VARCHAR}"); } if (record.getIp() != null) { @@ -178,7 +187,8 @@ public class HighUserLoginLogSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); sql.SET("user_phone = #{record.userPhone,jdbcType=VARCHAR}"); - sql.SET("platform = #{record.platform,jdbcType=VARCHAR}"); + sql.SET("platform_code = #{record.platformCode,jdbcType=VARCHAR}"); + sql.SET("platform_name = #{record.platformName,jdbcType=VARCHAR}"); sql.SET("ip = #{record.ip,jdbcType=VARCHAR}"); sql.SET("province_name = #{record.provinceName,jdbcType=VARCHAR}"); sql.SET("city_code = #{record.cityCode,jdbcType=VARCHAR}"); @@ -206,8 +216,12 @@ public class HighUserLoginLogSqlProvider { sql.SET("user_phone = #{userPhone,jdbcType=VARCHAR}"); } - if (record.getPlatform() != null) { - sql.SET("platform = #{platform,jdbcType=VARCHAR}"); + if (record.getPlatformCode() != null) { + sql.SET("platform_code = #{platformCode,jdbcType=VARCHAR}"); + } + + if (record.getPlatformName() != null) { + sql.SET("platform_name = #{platformName,jdbcType=VARCHAR}"); } if (record.getIp() != null) { diff --git a/hai-service/src/main/java/com/hai/dao/order/OrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/order/OrderMapperExt.java index 5c998c75..c9600008 100644 --- a/hai-service/src/main/java/com/hai/dao/order/OrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/order/OrderMapperExt.java @@ -31,9 +31,11 @@ public interface OrderMapperExt { " a.goods_name couponName," + " a.goods_price couponPrice," + " b.total_price totalPrice," + - " b.deduction_price deductionPrice," + + " b.total_deduction_price totalDeductionPrice," + + " b.deduction_coupon_price deductionCouponPrice," + + " b.deduction_product_price deductionProductPrice," + " b.payable_price payablePrice," + - " b.pay_gold payGold," + + " b.pay_gold/100 payGold," + " b.pay_price payPrice," + " CASE b.pay_type " + " WHEN 1 THEN '支付宝' " + @@ -81,7 +83,9 @@ public interface OrderMapperExt { " b.mem_phone memPhone," + " a.goods_price*100 goodsPrice," + " b.total_price totalPrice," + - " b.deduction_price deductionPrice," + + " b.total_deduction_price totalDeductionPrice," + + " b.deduction_coupon_price deductionCouponPrice," + + " b.deduction_product_price deductionProductPrice," + " b.payable_price payablePrice," + " b.pay_gold payGold," + " b.pay_price payPrice," + diff --git a/hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java b/hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java index 015f9f16..68083869 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserLoginLog.java @@ -29,9 +29,14 @@ public class HighUserLoginLog implements Serializable { private String userPhone; /** - * 登录平台 + * 登录平台code */ - private String platform; + private String platformCode; + + /** + * 登录平台名称 + */ + private String platformName; /** * ip地址 @@ -104,12 +109,20 @@ public class HighUserLoginLog implements Serializable { this.userPhone = userPhone; } - public String getPlatform() { - return platform; + public String getPlatformCode() { + return platformCode; + } + + public void setPlatformCode(String platformCode) { + this.platformCode = platformCode; + } + + public String getPlatformName() { + return platformName; } - public void setPlatform(String platform) { - this.platform = platform; + public void setPlatformName(String platformName) { + this.platformName = platformName; } public String getIp() { @@ -199,7 +212,8 @@ public class HighUserLoginLog implements Serializable { return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getUserPhone() == null ? other.getUserPhone() == null : this.getUserPhone().equals(other.getUserPhone())) - && (this.getPlatform() == null ? other.getPlatform() == null : this.getPlatform().equals(other.getPlatform())) + && (this.getPlatformCode() == null ? other.getPlatformCode() == null : this.getPlatformCode().equals(other.getPlatformCode())) + && (this.getPlatformName() == null ? other.getPlatformName() == null : this.getPlatformName().equals(other.getPlatformName())) && (this.getIp() == null ? other.getIp() == null : this.getIp().equals(other.getIp())) && (this.getProvinceName() == null ? other.getProvinceName() == null : this.getProvinceName().equals(other.getProvinceName())) && (this.getCityCode() == null ? other.getCityCode() == null : this.getCityCode().equals(other.getCityCode())) @@ -218,7 +232,8 @@ public class HighUserLoginLog implements Serializable { result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getUserPhone() == null) ? 0 : getUserPhone().hashCode()); - result = prime * result + ((getPlatform() == null) ? 0 : getPlatform().hashCode()); + result = prime * result + ((getPlatformCode() == null) ? 0 : getPlatformCode().hashCode()); + result = prime * result + ((getPlatformName() == null) ? 0 : getPlatformName().hashCode()); result = prime * result + ((getIp() == null) ? 0 : getIp().hashCode()); result = prime * result + ((getProvinceName() == null) ? 0 : getProvinceName().hashCode()); result = prime * result + ((getCityCode() == null) ? 0 : getCityCode().hashCode()); @@ -240,7 +255,8 @@ public class HighUserLoginLog implements Serializable { sb.append(", id=").append(id); sb.append(", userId=").append(userId); sb.append(", userPhone=").append(userPhone); - sb.append(", platform=").append(platform); + sb.append(", platformCode=").append(platformCode); + sb.append(", platformName=").append(platformName); sb.append(", ip=").append(ip); sb.append(", provinceName=").append(provinceName); sb.append(", cityCode=").append(cityCode); diff --git a/hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java b/hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java index b526a695..e693afce 100644 --- a/hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighUserLoginLogExample.java @@ -315,73 +315,143 @@ public class HighUserLoginLogExample { return (Criteria) this; } - public Criteria andPlatformIsNull() { - addCriterion("platform is null"); + public Criteria andPlatformCodeIsNull() { + addCriterion("platform_code is null"); return (Criteria) this; } - public Criteria andPlatformIsNotNull() { - addCriterion("platform is not null"); + public Criteria andPlatformCodeIsNotNull() { + addCriterion("platform_code is not null"); return (Criteria) this; } - public Criteria andPlatformEqualTo(String value) { - addCriterion("platform =", value, "platform"); + public Criteria andPlatformCodeEqualTo(String value) { + addCriterion("platform_code =", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformNotEqualTo(String value) { - addCriterion("platform <>", value, "platform"); + public Criteria andPlatformCodeNotEqualTo(String value) { + addCriterion("platform_code <>", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformGreaterThan(String value) { - addCriterion("platform >", value, "platform"); + public Criteria andPlatformCodeGreaterThan(String value) { + addCriterion("platform_code >", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformGreaterThanOrEqualTo(String value) { - addCriterion("platform >=", value, "platform"); + public Criteria andPlatformCodeGreaterThanOrEqualTo(String value) { + addCriterion("platform_code >=", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformLessThan(String value) { - addCriterion("platform <", value, "platform"); + public Criteria andPlatformCodeLessThan(String value) { + addCriterion("platform_code <", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformLessThanOrEqualTo(String value) { - addCriterion("platform <=", value, "platform"); + public Criteria andPlatformCodeLessThanOrEqualTo(String value) { + addCriterion("platform_code <=", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformLike(String value) { - addCriterion("platform like", value, "platform"); + public Criteria andPlatformCodeLike(String value) { + addCriterion("platform_code like", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformNotLike(String value) { - addCriterion("platform not like", value, "platform"); + public Criteria andPlatformCodeNotLike(String value) { + addCriterion("platform_code not like", value, "platformCode"); return (Criteria) this; } - public Criteria andPlatformIn(List values) { - addCriterion("platform in", values, "platform"); + public Criteria andPlatformCodeIn(List values) { + addCriterion("platform_code in", values, "platformCode"); return (Criteria) this; } - public Criteria andPlatformNotIn(List values) { - addCriterion("platform not in", values, "platform"); + public Criteria andPlatformCodeNotIn(List values) { + addCriterion("platform_code not in", values, "platformCode"); return (Criteria) this; } - public Criteria andPlatformBetween(String value1, String value2) { - addCriterion("platform between", value1, value2, "platform"); + public Criteria andPlatformCodeBetween(String value1, String value2) { + addCriterion("platform_code between", value1, value2, "platformCode"); return (Criteria) this; } - public Criteria andPlatformNotBetween(String value1, String value2) { - addCriterion("platform not between", value1, value2, "platform"); + public Criteria andPlatformCodeNotBetween(String value1, String value2) { + addCriterion("platform_code not between", value1, value2, "platformCode"); + return (Criteria) this; + } + + public Criteria andPlatformNameIsNull() { + addCriterion("platform_name is null"); + return (Criteria) this; + } + + public Criteria andPlatformNameIsNotNull() { + addCriterion("platform_name is not null"); + return (Criteria) this; + } + + public Criteria andPlatformNameEqualTo(String value) { + addCriterion("platform_name =", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameNotEqualTo(String value) { + addCriterion("platform_name <>", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameGreaterThan(String value) { + addCriterion("platform_name >", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameGreaterThanOrEqualTo(String value) { + addCriterion("platform_name >=", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameLessThan(String value) { + addCriterion("platform_name <", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameLessThanOrEqualTo(String value) { + addCriterion("platform_name <=", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameLike(String value) { + addCriterion("platform_name like", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameNotLike(String value) { + addCriterion("platform_name not like", value, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameIn(List values) { + addCriterion("platform_name in", values, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameNotIn(List values) { + addCriterion("platform_name not in", values, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameBetween(String value1, String value2) { + addCriterion("platform_name between", value1, value2, "platformName"); + return (Criteria) this; + } + + public Criteria andPlatformNameNotBetween(String value1, String value2) { + addCriterion("platform_name not between", value1, value2, "platformName"); return (Criteria) this; } diff --git a/hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java b/hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java index 43413286..11bcd20b 100644 --- a/hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java +++ b/hai-service/src/main/java/com/hai/enum_type/LoginPlatform.java @@ -9,7 +9,7 @@ import java.util.Objects; * @date: 2022/10/20 **/ public enum LoginPlatform { - H5("WEB", "H5客户端"), + H5("H5", "H5客户端"), WXAPPLETS("WXAPPLETS", "微信小程序"), UNIONPAY("UNIONPAY", "云闪付"), ; diff --git a/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java b/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java index d82215a9..a8f746f1 100644 --- a/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java +++ b/hai-service/src/main/java/com/hai/order/model/ExportGasOrderModel.java @@ -48,11 +48,11 @@ public class ExportGasOrderModel { @ExcelProperty({ "加油信息", "油枪号"}) private String gasGunNo; - @ColumnWidth(10) + @ColumnWidth(15) @ExcelProperty({ "加油信息", "平台折扣"}) private String gasDiscount; - @ColumnWidth(10) + @ColumnWidth(15) @ExcelProperty({ "加油信息", "平台补贴"}) private BigDecimal gasOilSubsidy; @@ -68,9 +68,17 @@ public class ExportGasOrderModel { @ExcelProperty({ "加油信息", "国标价"}) private BigDecimal gasPriceOfficial; + @ColumnWidth(15) + @ExcelProperty({ "支付信息", "总优惠"}) + private BigDecimal totalDeductionPrice; + + @ColumnWidth(15) + @ExcelProperty({ "支付信息", "优惠券优惠"}) + private BigDecimal deductionCouponPrice; + @ColumnWidth(15) @ExcelProperty({ "支付信息", "加油优惠"}) - private BigDecimal deductionPrice; + private BigDecimal deductionProductPrice; @ColumnWidth(15) @ExcelProperty({ "支付信息", "应付金额"}) diff --git a/hai-service/src/main/java/com/hai/order/model/OrderCouponModel.java b/hai-service/src/main/java/com/hai/order/model/OrderCouponModel.java index 4f30272d..5423c7e7 100644 --- a/hai-service/src/main/java/com/hai/order/model/OrderCouponModel.java +++ b/hai-service/src/main/java/com/hai/order/model/OrderCouponModel.java @@ -37,8 +37,16 @@ public class OrderCouponModel { private BigDecimal totalPrice; @ColumnWidth(13) - @ExcelProperty(value = "优惠价格") - private BigDecimal deductionPrice; + @ExcelProperty(value = "总优惠") + private BigDecimal totalDeductionPrice; + + @ColumnWidth(15) + @ExcelProperty(value = "优惠券优惠") + private BigDecimal deductionCouponPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "产品优惠") + private BigDecimal deductionProductPrice; @ColumnWidth(13) @ExcelProperty(value = "应付金额") diff --git a/hai-service/src/main/java/com/hai/order/model/OrderIntegralRechargeModel.java b/hai-service/src/main/java/com/hai/order/model/OrderIntegralRechargeModel.java index 7cce6ce9..c9bae241 100644 --- a/hai-service/src/main/java/com/hai/order/model/OrderIntegralRechargeModel.java +++ b/hai-service/src/main/java/com/hai/order/model/OrderIntegralRechargeModel.java @@ -33,8 +33,16 @@ public class OrderIntegralRechargeModel { private BigDecimal totalPrice; @ColumnWidth(13) - @ExcelProperty(value = "优惠价格") - private BigDecimal deductionPrice; + @ExcelProperty(value = "总优惠金额") + private BigDecimal totalDeductionPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "优惠券优惠金额") + private BigDecimal deductionCouponPrice; + + @ColumnWidth(13) + @ExcelProperty(value = "产品优惠金额") + private BigDecimal deductionProductPrice; @ColumnWidth(13) @ExcelProperty(value = "应付金额") diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 7a2c4aad..4063ae9e 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -391,7 +391,6 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { .setScale(2, BigDecimal.ROUND_HALF_DOWN); gasOrder.setDeductionCouponPrice(gasOrder.getGasRefuelPrice().subtract(deductionPrice)); } - gasOrder.setPayablePrice(gasOrder.getGasRefuelPrice().subtract(gasOrder.getTotalDeductionPrice())); if (gasOrder.getPayablePrice().compareTo(new BigDecimal("0")) < 0) { gasOrder.setPayablePrice(new BigDecimal("0")); @@ -410,7 +409,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { } else { // 支付价格 childOrder.setGoodsActualPrice(priceModel.getPayPrice()); - gasOrder.setDeductionCouponPrice(priceModel.getTotalPreferences()); + gasOrder.setDeductionProductPrice(priceModel.getTotalPreferences()); gasOrder.setPayablePrice(priceModel.getPayPrice()); // 油价信息 @@ -425,6 +424,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { gasOrder.setGasPricePreferences(priceModel.getPricePreferences()); } childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); + gasOrder.setTotalDeductionPrice(gasOrder.getDeductionProductPrice().add(gasOrder.getDeductionCouponPrice())); gasOrder.setPayGold(createOrderModel.getPayGold()!=null?createOrderModel.getPayGold():0); if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { diff --git a/hai-service/src/main/java/com/hai/service/HighUserService.java b/hai-service/src/main/java/com/hai/service/HighUserService.java index 9adbf653..ce2d6886 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserService.java @@ -1,11 +1,13 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; +import com.hai.common.security.SessionObject; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; @@ -26,7 +28,7 @@ public interface HighUserService { * @return * @throws Exception */ - HighUserModel loginAndRegister(LoginPlatform platForm, String phone, Long popularizeUserId, Map other) throws Exception; + SessionObject loginAndRegister(LoginPlatform platForm, String phone, Long popularizeUserId, Map other, HttpServletRequest request, HttpServletResponse response) throws Exception; /** * diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index e5de6753..3b676d51 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -80,12 +81,13 @@ public class HighUserServiceImpl implements HighUserService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW, timeout = 30, rollbackFor = Exception.class) - public HighUserModel loginAndRegister(LoginPlatform platform,String phone, Long popularizeUserId, Map other) throws Exception { + public SessionObject loginAndRegister(LoginPlatform platform,String phone, Long popularizeUserId, Map other,HttpServletRequest request, HttpServletResponse response) throws Exception { // 记录登录信息 String requestIp = RequestUtils.getRequestIp(); HighUserLoginLog loginLog = new HighUserLoginLog(); loginLog.setUserPhone(phone); - loginLog.setPlatform(platform.getName()); + loginLog.setPlatformCode(platform.getCode()); + loginLog.setPlatformName(platform.getName()); loginLog.setIp(requestIp); loginLog.setProvinceName("未知"); loginLog.setCityName("未知"); @@ -124,7 +126,6 @@ public class HighUserServiceImpl implements HighUserService { distributionUserRelService.insertDistributionRebate(user.getId(), popularizeUserId, region.getRegionId().toString()); } } - loginLog.setUserId(user.getId()); userLoginLogMapper.insert(loginLog); @@ -132,9 +133,9 @@ public class HighUserServiceImpl implements HighUserService { HighUserModel highUserModel = new HighUserModel(); highUserModel.setHighUser(getDetailDataByUser(user.getId())); SessionObject so = new SessionObject(AESEncodeUtil.base64Encode(AESEncodeUtil.aesEncryptToBytes(user.getPhone(), "123")), 1 , highUserModel); - userCenter.save(null,null,so); + userCenter.save(request,response,so); - return highUserModel; + return so; } @Override diff --git a/hai-service/src/main/java/com/hai/user/service/UserLoginLogService.java b/hai-service/src/main/java/com/hai/user/service/UserLoginLogService.java new file mode 100644 index 00000000..06a114d4 --- /dev/null +++ b/hai-service/src/main/java/com/hai/user/service/UserLoginLogService.java @@ -0,0 +1,23 @@ +package com.hai.user.service; + +import com.hai.entity.HighUserLoginLog; + +import java.util.List; +import java.util.Map; + +/** + * 用户登录日志 + * @className: UserLoginService + * @author: HuRui + * @date: 2022/10/25 + **/ +public interface UserLoginLogService { + + /** + * 查询用户登录日志列表 + * @param param + * @return + */ + List getUserLoginLogList(Map param); + +} diff --git a/hai-service/src/main/java/com/hai/user/service/impl/UserLoginLogServiceImpl.java b/hai-service/src/main/java/com/hai/user/service/impl/UserLoginLogServiceImpl.java new file mode 100644 index 00000000..c8b52e1f --- /dev/null +++ b/hai-service/src/main/java/com/hai/user/service/impl/UserLoginLogServiceImpl.java @@ -0,0 +1,37 @@ +package com.hai.user.service.impl; + +import com.hai.dao.HighUserLoginLogMapper; +import com.hai.entity.HighUserLoginLog; +import com.hai.entity.HighUserLoginLogExample; +import com.hai.user.service.UserLoginLogService; +import org.apache.commons.collections4.MapUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * @className: UserLoginLogServiceImpl + * @author: HuRui + * @date: 2022/10/25 + **/ +@Service("userLoginLogService") +public class UserLoginLogServiceImpl implements UserLoginLogService { + + @Resource + private HighUserLoginLogMapper userLoginLogMapper; + + @Override + public List getUserLoginLogList(Map param) { + HighUserLoginLogExample example = new HighUserLoginLogExample(); + HighUserLoginLogExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); + + if (MapUtils.getLong(param, "userId") != null) { + criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId")); + } + + example.setOrderByClause("create_time desc"); + return userLoginLogMapper.selectByExample(example); + } +} diff --git a/hai-user/src/main/java/com/web/controller/LoginController.java b/hai-user/src/main/java/com/web/controller/LoginController.java index a484df79..084821df 100644 --- a/hai-user/src/main/java/com/web/controller/LoginController.java +++ b/hai-user/src/main/java/com/web/controller/LoginController.java @@ -1 +1 @@ -package com.web.controller; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.HighUserService; import com.web.config.WxMaConfiguration; import com.web.type.LoginType; import com.hai.enum_type.RedisFileFolder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/login") @Api(value = "登录业务") public class LoginController { private static Logger log = LoggerFactory.getLogger(LoginController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @Resource private WxMaConfiguration wxMaConfiguration; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/phone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "手机号登录") public ResponseData phone(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("phone")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.SMS.getCode())) { if (StringUtils.isBlank(body.getString("smsCode"))) { log.error("LoginController --> phone() error!", "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); } // 手机号的验证码 Object phoneCodeObject = redisUtil.get(RedisFileFolder.SMS_CODE.getCode() + phone); if (phoneCodeObject == null) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } // redisUtil.del(RedisFileFolder.SMS_CODE.getCode() + phone); return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, body.getLong("popularizeUserId"), new HashMap<>())); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMiniHandleCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序code解析") public ResponseData wxMiniHandleCode(@RequestBody JSONObject body) { try { if (body == null|| StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } //请求微信api,获取用户session_key以及openId WxMaJscode2SessionResult session = WxMaConfiguration.getMaService().jsCode2SessionInfo(body.getString("code")); //保存小程序用户登录的openId及sessionKey信息 redisUtil.hset("WX_OPENID_SESSION_REDIS", session.getOpenid(), session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMini", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序") public ResponseData wxMini(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("encryptedData")) || StringUtils.isBlank(body.getString("iv")) || StringUtils.isBlank(body.getString("openId"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String encryptedData = body.getString("encryptedData").replace(" ", "+"); String iv = body.getString("iv").replace(" ", "+"); //请求微信api,获取用户session_key以及openId Object skObject = redisUtil.hget("WX_OPENID_SESSION_REDIS", body.getString("openId")); if (skObject == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); } WxMaJscode2SessionResult session = (WxMaJscode2SessionResult) skObject; WxMaPhoneNumberInfo phoneNoInfo = WxMaConfiguration .getMaService() .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { log.error("LoginController --> wxMini() error!", "登录失败! 用户手机号解析失败"); throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "登录失败! 用户手机号解析失败"); } Map other = new HashMap<>(); other.put("openId", session.getOpenid()); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.WXAPPLETS, phoneNoInfo.getPurePhoneNumber(), body.getLong("popularizeUserId"), other)); } catch (Exception e) { log.error("LoginController --> wxMini() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/union", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData union(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 获取应用访问令牌 String backendToken = unionUserConfig.getBackendToken(); // 获取授权访问令牌 JSONObject token = unionUserConfig.getAccessToken(backendToken, body.getString("code")); if (token == null || !token.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, token.getString("msg")); } // 获取用户手机号 JSONObject userMobile = unionUserConfig.getUserMobile(backendToken, token.getJSONObject("params").getString("accessToken"), token.getJSONObject("params").getString("openId")); if (userMobile == null || !userMobile.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userMobile.getString("msg")); } // 解密,获取手机号 String mobile = UnionUtils.getDecryptedValue(userMobile.getJSONObject("params").getString("mobile"), unionUserConfig.getRsaKey()); Map other = new HashMap<>(); other.put("unionId", token.getJSONObject("params").getString("openId")); other.put("unionUnionId", token.getJSONObject("params").getString("unionId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.UNIONPAY, mobile, body.getLong("popularizeUserId"), other)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.web.controller; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.HighUserService; import com.web.config.WxMaConfiguration; import com.web.type.LoginType; import com.hai.enum_type.RedisFileFolder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/login") @Api(value = "登录业务") public class LoginController { private static Logger log = LoggerFactory.getLogger(LoginController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @Resource private UserCenter userCenter; @Resource private WxMaConfiguration wxMaConfiguration; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/phone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "手机号登录") public ResponseData phone(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("phone")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.SMS.getCode())) { if (StringUtils.isBlank(body.getString("smsCode"))) { log.error("LoginController --> phone() error!", "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); } // 手机号的验证码 Object phoneCodeObject = redisUtil.get(RedisFileFolder.SMS_CODE.getCode() + phone); if (phoneCodeObject == null) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } redisUtil.del(RedisFileFolder.SMS_CODE.getCode() + phone); return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMiniHandleCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序code解析") public ResponseData wxMiniHandleCode(@RequestBody JSONObject body) { try { if (body == null|| StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } //请求微信api,获取用户session_key以及openId WxMaJscode2SessionResult session = WxMaConfiguration.getMaService().jsCode2SessionInfo(body.getString("code")); //保存小程序用户登录的openId及sessionKey信息 redisUtil.hset("WX_OPENID_SESSION_REDIS", session.getOpenid(), session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMini", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序") public ResponseData wxMini(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("encryptedData")) || StringUtils.isBlank(body.getString("iv")) || StringUtils.isBlank(body.getString("openId"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String encryptedData = body.getString("encryptedData").replace(" ", "+"); String iv = body.getString("iv").replace(" ", "+"); //请求微信api,获取用户session_key以及openId Object skObject = redisUtil.hget("WX_OPENID_SESSION_REDIS", body.getString("openId")); if (skObject == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); } WxMaJscode2SessionResult session = (WxMaJscode2SessionResult) skObject; WxMaPhoneNumberInfo phoneNoInfo = WxMaConfiguration .getMaService() .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { log.error("LoginController --> wxMini() error!", "登录失败! 用户手机号解析失败"); throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "登录失败! 用户手机号解析失败"); } Map other = new HashMap<>(); other.put("openId", session.getOpenid()); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.WXAPPLETS, phoneNoInfo.getPurePhoneNumber(), body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { log.error("LoginController --> wxMini() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/union", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData union(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 获取应用访问令牌 String backendToken = unionUserConfig.getBackendToken(); // 获取授权访问令牌 JSONObject token = unionUserConfig.getAccessToken(backendToken, body.getString("code")); if (token == null || !token.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, token.getString("msg")); } // 获取用户手机号 JSONObject userMobile = unionUserConfig.getUserMobile(backendToken, token.getJSONObject("params").getString("accessToken"), token.getJSONObject("params").getString("openId")); if (userMobile == null || !userMobile.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userMobile.getString("msg")); } // 解密,获取手机号 String mobile = UnionUtils.getDecryptedValue(userMobile.getJSONObject("params").getString("mobile"), unionUserConfig.getRsaKey()); Map other = new HashMap<>(); other.put("unionId", token.getJSONObject("params").getString("openId")); other.put("unionUnionId", token.getJSONObject("params").getString("unionId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.UNIONPAY, mobile, body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/out", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "退出登录") public ResponseData out(HttpServletRequest request, HttpServletResponse response) { try { HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); if (userInfoModel == null) { log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); } userCenter.remove(request, response); return ResponseMsgUtil.success("退出登录成功"); } catch (Exception e) { log.error("CoresController --> outLogin() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-user/src/main/java/com/web/controller/LoginLogController.java b/hai-user/src/main/java/com/web/controller/LoginLogController.java new file mode 100644 index 00000000..f521e322 --- /dev/null +++ b/hai-user/src/main/java/com/web/controller/LoginLogController.java @@ -0,0 +1 @@ +package com.web.controller; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.user.service.UserLoginLogService; 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; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/loginLog") @Api(value = "登录日志") public class LoginLogController { private static Logger log = LoggerFactory.getLogger(LoginLogController.class); @Resource private UserCenter userCenter; @Resource private UserLoginLogService userLoginLogService; @RequestMapping(value = "/getUserLoginLogList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取用户登录日志列表") public ResponseData getUserLoginLogList(@RequestParam(value = "pageNum", required = true) Integer pageNum, @RequestParam(value = "pageSize", required = true) Integer pageSize) { try { HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); if (userInfoModel == null) { log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); } Map param = new HashMap<>(); param.put("userId", userInfoModel.getHighUser().getId()); PageHelper.startPage(pageNum, pageSize); return ResponseMsgUtil.success(new PageInfo<>(userLoginLogService.getUserLoginLogList(param))); } catch (Exception e) { log.error("loginLog --> getUserLoginLogList() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-user/src/main/java/com/web/controller/CoresController.java b/hai-user/src/main/java/com/web/controller/UserController.java similarity index 78% rename from hai-user/src/main/java/com/web/controller/CoresController.java rename to hai-user/src/main/java/com/web/controller/UserController.java index fd7124cc..2b0fd861 100644 --- a/hai-user/src/main/java/com/web/controller/CoresController.java +++ b/hai-user/src/main/java/com/web/controller/UserController.java @@ -5,29 +5,23 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; -import com.hai.common.utils.MemberValidateUtil; import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.HighOilCard; import com.hai.entity.HighUserCard; -import com.hai.enum_type.LoginPlatform; -import com.hai.enum_type.RedisFileFolder; import com.hai.enum_type.UserCardType; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; -import com.hai.model.UserInfoModel; import com.hai.service.HighOilCardService; import com.hai.service.HighUserCardService; import com.hai.service.HighUserService; -import com.web.type.LoginType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -46,11 +40,11 @@ import java.util.Map; **/ @Controller -@RequestMapping(value = "/cores") +@RequestMapping(value = "/") @Api(value = "用户核心业务") -public class CoresController { +public class UserController { - private static Logger log = LoggerFactory.getLogger(CoresController.class); + private static Logger log = LoggerFactory.getLogger(UserController.class); @Resource private RedisUtil redisUtil; @@ -128,23 +122,4 @@ public class CoresController { } } - @RequestMapping(value = "/outLogin", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "退出登录") - public ResponseData outLogin(HttpServletRequest request, HttpServletResponse response) { - try { - HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); - if (userInfoModel == null) { - log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); - } - userCenter.remove(request, response); - return ResponseMsgUtil.success("退出登录成功"); - - } catch (Exception e) { - log.error("CoresController --> outLogin() error!", e); - return ResponseMsgUtil.exception(e); - } - } - } diff --git a/hai-user/src/main/resources/dev/config.properties b/hai-user/src/main/resources/dev/config.properties index 64ff8af1..78e36477 100644 --- a/hai-user/src/main/resources/dev/config.properties +++ b/hai-user/src/main/resources/dev/config.properties @@ -1,27 +1,5 @@ -# \u03A2\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD -wxAppId=wx8d49e2f83025229d -wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df -wxH5AppId=wxa075e8509802f826 -wxH5AppSecret=0e606fc1378d35e359fcf3f15570b2c5 - -wxApiKey=Skufk5oi85wDFGl888i6wsRSTkdd5df5 -wxMchAppId=wx637bd6f7314daa46 -wxMchId=1289663601 -wxSubAppId=wx8d49e2f83025229d -wxSubMchId=1609882817 -wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder -wxGzSubAppId=wxa075e8509802f826 -wxGzSubMchId=1619676214 - -# ???????????? -HDAppId = 1614670195 - -notifyUrl=https://hsgcs.dctpay.com/crest/wechatpay/notify -imgUrl=https://hsgcs.dctpay.com/filesystem/ +wxMiniAppId=wx8d49e2f83025229d +wxMiniAppSecret=d8d6dcaef77d3b659258a01b5ddba5df fileUrl=/home/project/hsg/filesystem -cmsPath=/home/project/hsg/filesystem/cmsPath -couponCodePath=/home/project/hsg/filesystem/couponCode - -qrCodeUrl=https://hsgcs.dctpay.com/hsgH5?accountId=0000010&key=&code=