diff --git a/cweb/src/main/java/com/cweb/controller/BsUserController.java b/cweb/src/main/java/com/cweb/controller/BsUserController.java index d7ecd0e..1dd88c9 100644 --- a/cweb/src/main/java/com/cweb/controller/BsUserController.java +++ b/cweb/src/main/java/com/cweb/controller/BsUserController.java @@ -9,6 +9,7 @@ import com.hfkj.common.alipay.AlipayUtils; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; +import com.hfkj.common.pay.util.SignatureUtil; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.HttpsUtils; import com.hfkj.common.utils.MemberValidateUtil; @@ -58,16 +59,24 @@ public class BsUserController { @RequestMapping(value = "/autoLogin", method = RequestMethod.POST) @ResponseBody - @ApiOperation(value = "登录并注册") + @ApiOperation(value = "自动登录并注册") public ResponseData autoLogin(@RequestBody JSONObject body) { try { if (body == null || StringUtils.isBlank(body.getString("appid")) - || StringUtils.isBlank(body.getString("phone"))) { + || StringUtils.isBlank(body.getString("phone")) + || StringUtils.isBlank(body.getString("sign")) + ) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 接入appid BsAgentApiParam agentApiParam = agentApiParamService.getParamByAppId(body.getString("appid")); + + // 验证签名 + BsAgentApiParam apiParam = agentApiParamService.getParamByAppId(agentApiParam.getAppId()); + if (!SignatureUtil.checkSign(body.getString("sign"), body, apiParam.getAppSecret())) { + throw ErrorHelp.genException(SysCode.OpenApi, ErrorCode.OPEN_API_SIGN_ERR, ""); + } String phone = body.getString("phone"); Map other = new HashMap<>(); @@ -77,7 +86,7 @@ public class BsUserController { return ResponseMsgUtil.success(userService.login(UserLoginPlatform.TRIPARTITE, UserLoginType.TRIPARTITE, phone, other)); } catch (Exception e) { - log.error("LoginController --> phone() error!", e); + log.error("LoginController --> autoLogin() error!", e); return ResponseMsgUtil.exception(e); } } diff --git a/schedule/src/main/java/com/hfkj/schedule/DiscountSchedule.java b/schedule/src/main/java/com/hfkj/schedule/DiscountSchedule.java index 6feabd8..9d2c63c 100644 --- a/schedule/src/main/java/com/hfkj/schedule/DiscountSchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/DiscountSchedule.java @@ -1,10 +1,17 @@ package com.hfkj.schedule; +import com.hfkj.entity.BsDiscount; +import com.hfkj.service.discount.BsDiscountService; import com.hfkj.service.discount.BsDiscountUserService; +import com.hfkj.sysenum.discount.DiscountStatusEnum; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @className: DiscountSchedule @@ -16,15 +23,39 @@ public class DiscountSchedule { @Resource private BsDiscountUserService discountUserService; - + @Resource + private BsDiscountService discountService; + /** + * 用户优惠券过期 + */ @Scheduled(cron="0 0/1 * * * ?") //每分钟执行一次 - public void newLinkGasSchedule() { + public void userDiscountExpiration() { try { // 更新过期数据 discountUserService.expiration();; } catch (Exception e) { - System.out.println("更新价格失败!!!"); + System.out.println("更新失败!!!"); + } + } + + /** + * 优惠券过期 + */ + @Scheduled(cron="0 0/30 * * * ?") //每30分钟执行一次 + public void discountExpiration() { + try { + Map param = new HashMap<>(); + param.put("status", DiscountStatusEnum.status2.getCode()); + param.put("endTimeE", System.currentTimeMillis()); + + List list = discountService.getList(param); + for (BsDiscount discount : list) { + discountService.done(discount.getDiscountNo()); + } + + } catch (Exception e) { + System.out.println("更新失败!!!"); } } diff --git a/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumRequestService.java b/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumRequestService.java index 2fcdd9e..95db8fd 100644 --- a/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumRequestService.java +++ b/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumRequestService.java @@ -62,7 +62,7 @@ public class CqShellPetroleumRequestService { Map param = new HashMap<>(); param.put("platMerchantId", PLAT_MERCHANT_ID); param.put("stationCode", stationCode); - return request(System.currentTimeMillis()+"","gasPageQueryAllStation", param); + return request(System.currentTimeMillis()+"","gasStationQueryDetail", param); } catch (Exception e) { e.printStackTrace(); } diff --git a/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java b/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java index b9b2798..a29a56b 100644 --- a/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java +++ b/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java @@ -81,12 +81,9 @@ public class SignatureUtil { } public static void main(String[] args) throws Exception { - String paramStr = "{ \n" + - " \"reqId\": \"cs0005\",\n" + - " \"appId\": \"hf7356c71fb97ab0\",\n" + - " \"discountPkNo\": \"DPK10018\",\n" + - " \"number\": \"1\",\n" + - " \"phone\": \"17726395120\"" + + String paramStr = "{\n" + + "\t\"appid\": \"hf7356c71fb97ab0\",\n" + + "\t\"phone\": \"17726395120\"" + "}"; String sign = createSign(JSONObject.parseObject(paramStr), "8aef995ff71485dc19b36e35f04c4016"); System.out.println(sign); diff --git a/service/src/main/java/com/hfkj/service/discount/impl/BsDiscountServiceImpl.java b/service/src/main/java/com/hfkj/service/discount/impl/BsDiscountServiceImpl.java index 4e5d36c..a659a0f 100644 --- a/service/src/main/java/com/hfkj/service/discount/impl/BsDiscountServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/discount/impl/BsDiscountServiceImpl.java @@ -160,6 +160,10 @@ public class BsDiscountServiceImpl implements BsDiscountService { criteria.andCreateUserIdEqualTo(MapUtils.getLong(param, "createUserId") ); } + if (MapUtils.getLong(param, "endTimeE") != null) { + criteria.andEndTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "endTimeE"))); + } + example.setOrderByClause("create_time desc"); return discountMapper.selectByExample(example); }