| | |
| | | import com.dsh.activity.model.response.*; |
| | | import com.dsh.activity.service.*; |
| | | import com.dsh.activity.util.*; |
| | | import com.dsh.activity.util.wx.WxV3PayConfig; |
| | | import com.google.gson.Gson; |
| | | import io.swagger.annotations.*; |
| | | import io.swagger.models.auth.In; |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/huimin") |
| | | @Api(tags = "惠民卡新增") |
| | | @Api(tags = "玩湃惠民卡新增") |
| | | public class HuiminController { |
| | | |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | private String smid = "2088330203191220";//平台支付宝商户号 |
| | | // todo 待申请 |
| | | private String smidVx = "2088330203191220";//平台微信商户号 |
| | | |
| | | |
| | | /** |
| | | * 查看惠民卡详情 |
| | | * 查看玩湃惠民卡详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/payHuiminCard") |
| | | @ApiOperation(value = "购买惠民卡") |
| | | @ApiOperation(value = "购买玩湃惠民卡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "惠民卡id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "玩湃惠民卡id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "支付方式1微信2支付宝", name = "payType", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "绑定学员ids多,个逗号拼接", name = "studentIds", dataType = "String", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | |
| | | } |
| | | THuiminCard huiminCard = huiminCardService.getById(id); |
| | | if (huiminCard.getEndTime() != null && huiminCard.getEndTime().before(new Date())) { |
| | | return ResultUtil.error("该惠民卡已过期"); |
| | | return ResultUtil.error("该玩湃惠民卡已过期"); |
| | | } |
| | | if (huiminCard.getGrantCount() != null) { |
| | | if (huiminCard.getGrantCount() <= payHuiminService.lambdaQuery().eq(TPayHuimin::getCardId, huiminCard.getId()) |
| | | .eq(TPayHuimin::getStatus, 2).count()) { |
| | | return ResultUtil.error("该惠民卡已售完"); |
| | | return ResultUtil.error("该玩湃惠民卡已售完"); |
| | | } |
| | | } |
| | | if (huiminCard.getLimitCount() != null) { |
| | |
| | | .eq(TPayHuimin::getStatus, 2) |
| | | .eq(TPayHuimin::getAppUserId, uid) |
| | | .count()) { |
| | | return ResultUtil.error("该惠民卡购买次数已达上限"); |
| | | return ResultUtil.error("该玩湃惠民卡购买次数已达上限"); |
| | | } |
| | | } |
| | | TPayHuimin tPayHuimin = new TPayHuimin(); |
| | |
| | | BigDecimal bigDecimal = new BigDecimal(studentIds.split(",").length); |
| | | switch (payType) { |
| | | case 1: |
| | | return payMoneyUtil.weixinpay("购买惠民卡" + "-" + 0, "", tPayHuimin.getCode(), tPayHuimin.getSalesMoney().toString(), |
| | | // todo 惠民卡收入属于平台商户 定死 |
| | | return payMoneyUtil.weixinpay("购买玩湃惠民卡", "", tPayHuimin.getCode(), tPayHuimin.getSalesMoney().toString(), |
| | | "/base/huimin/callBack/weixinPayHuiminCallback", "APP", ""); |
| | | // return payMoneyUtil.weixinpayV3("1720719391","购买玩湃惠民卡",tPayHuimin.getCode(), |
| | | // "/base/huimin/callBack/weixinPayHuiminCallback1",tPayHuimin.getSalesMoney().toString()); |
| | | case 2: |
| | | String string = tPayHuimin.getSalesMoney().toString(); |
| | | return payMoneyUtil.alipay(smid, "购买惠民卡", "购买惠民卡", "", tPayHuimin.getCode(), string, |
| | | return payMoneyUtil.alipay("2088670241691219", "购买玩湃惠民卡", "购买玩湃惠民卡", "", tPayHuimin.getCode(), string, |
| | | "/base/huimin/callBack/aliPayHuiminCallback"); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * 查看惠民卡详情 |
| | | * 查看玩湃惠民卡详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getHuiminCardDetail") |
| | | @ApiOperation(value = "查看惠民卡详情") |
| | | @ApiOperation(value = "查看玩湃惠民卡详情") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "惠民卡id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "玩湃惠民卡id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "门店id", name = "storeId", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | |
| | | } |
| | | |
| | | /** |
| | | * 惠民卡富文本内容-惠民卡列表 |
| | | * 玩湃惠民卡富文本内容-玩湃惠民卡列表 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getHuiminAgreementAndList") |
| | | @ApiOperation(value = "惠民卡富文本内容-惠民卡列表") |
| | | @ApiOperation(value = "玩湃惠民卡富文本内容-玩湃惠民卡列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageSize", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "页条数", name = "pageNo", dataType = "int", required = true), |
| | |
| | | |
| | | List<THuiminCard> cardListNolimit = huiminCardService.getHuiminAgreementAndListNolimit(storeId); |
| | | if (cardListNolimit.isEmpty()) { |
| | | // 没有配置惠民卡 展示富文本内容 |
| | | // 没有配置玩湃惠民卡 展示富文本内容 |
| | | huiminAgreementVO.setShowType(1); |
| | | } else { |
| | | huiminAgreementVO.setShowType(2); |
| | |
| | | if (tStudent!=null){ |
| | | huiminCardVO1.setStudentName(tStudent.getName()); |
| | | } |
| | | String temp = "{\"id\":"+payHuimin.getId() + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + payHuimin.getStudentId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}"; |
| | | String temp = "{\"id\":"+payHuimin.getId() + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tStudent.getId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}"; |
| | | huiminCardVO1.setQrCode(temp); |
| | | huiminCardVOS.add(huiminCardVO1); |
| | | integers.add(payHuimin.getCardId()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 惠民卡列表-根据惠民卡获取已购买绑定惠民卡的学员列表 |
| | | * 玩湃惠民卡列表-根据玩湃惠民卡获取已购买绑定玩湃惠民卡的学员列表 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getStudentListByCarId") |
| | | @ApiOperation(value = "惠民卡列表-根据惠民卡获取已购买绑定惠民卡的学员列表") |
| | | @ApiOperation(value = "玩湃惠民卡列表-根据玩湃惠民卡获取已购买绑定玩湃惠民卡的学员列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "惠民卡id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "玩湃惠民卡id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<TStudent>> getStudentListByCarId(Integer id) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 惠民卡列表-选择学员后返回对应的二维码生成规则和有效期结束时间 |
| | | * 玩湃惠民卡列表-选择学员后返回对应的二维码生成规则和有效期结束时间 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getQrCodeByStudentId") |
| | | @ApiOperation(value = "惠民卡列表-选择学员后返回对应的二维码生成规则和有效期结束时间") |
| | | @ApiOperation(value = "玩湃惠民卡列表-选择学员后返回对应的二维码生成规则和有效期结束时间") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "惠民卡id", name = "cardId", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "玩湃惠民卡id", name = "cardId", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "学员id", name = "studentId", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | String temp = "{\"id\":"+tPayHuimin.getId() + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tPayHuimin.getStudentId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}"; |
| | | huiminCardStudentVO.setQrCode(temp); |
| | | TStudent tStudent = tStudents.stream().filter(e -> e.getId().equals(studentId)).findFirst().orElse(null); |
| | | if (tStudent!=null){ |
| | | huiminCardStudentVO.setStudentName(tStudent.getName()); |
| | | } |
| | | String temp = "{\"id\":"+tPayHuimin.getId() + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tStudent.getId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}"; |
| | | huiminCardStudentVO.setQrCode(temp); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 惠民卡富文本内容-惠民卡列表 |
| | | * 玩湃惠民卡富文本内容-玩湃惠民卡列表 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/myHuiminCardList") |
| | | @ApiOperation(value = "个人中心-我的惠民卡") |
| | | @ApiOperation(value = "个人中心-我的玩湃惠民卡") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageSize", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "页条数", name = "pageNo", dataType = "int", required = true), |
| | |
| | | } |
| | | |
| | | /** |
| | | * 个人中心-我的惠民卡-退款 |
| | | * 个人中心-我的玩湃惠民卡-退款 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/refund") |
| | | @ApiOperation(value = "个人中心-我的惠民卡-退款") |
| | | @ApiOperation(value = "个人中心-我的玩湃惠民卡-退款") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "支付记录id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | TPayHuimin tPayHuimin = payHuiminService.getById(id); |
| | | if (tPayHuimin.getPaymentType()==3){ |
| | | // 后台录入直接退款 |
| | | tPayHuimin.setStatus(3); |
| | | payHuiminService.updateById(tPayHuimin); |
| | | return ResultUtil.success(); |
| | | } |
| | | if (tPayHuimin == null) { |
| | | return ResultUtil.error("订单不存在"); |
| | | } |
| | |
| | | |
| | | if (tPayHuimin.getEndTime().before(new Date())) { |
| | | // 已过期 |
| | | return ResultUtil.error("惠民卡已过期,不可退款"); |
| | | return ResultUtil.error("玩湃惠民卡已过期,不可退款"); |
| | | } |
| | | tPayHuimin.setStatus(4); |
| | | payHuiminService.updateById(tPayHuimin); |
| | | int count = huiminRecordService.list(new LambdaQueryWrapper<THuiminRecord>() |
| | | .eq(THuiminRecord::getPayId, tPayHuimin.getId())).size(); |
| | |
| | | // 购卡7日内没有使用记录可退款。超过7日不管有没有使用记录都不能退款 |
| | | if (new Date().after(DateUtil.addDay(tPayHuimin.getPaymentTime(), 7))) { |
| | | // 超过七天不可退款 |
| | | return ResultUtil.error("惠民卡购买超过七天,不可退款"); |
| | | return ResultUtil.error("玩湃惠民卡购买超过七天,不可退款"); |
| | | } else if (count > 0) { |
| | | return ResultUtil.error("惠民卡已使用,不可退款"); |
| | | return ResultUtil.error("玩湃惠民卡已使用,不可退款"); |
| | | } |
| | | if (tPayHuimin.getPaymentType() == 1) { |
| | | Map<String, String> map = payMoneyUtil.wxRefund(tPayHuimin.getOrderNumber(), tPayHuimin.getCode(), |
| | |
| | | |
| | | |
| | | /** |
| | | * 个人中心-我的惠民卡-查看详情 |
| | | * 个人中心-我的玩湃惠民卡-查看详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/myHuiminCardDetail") |
| | | @ApiOperation(value = "个人中心-我的惠民卡-查看详情") |
| | | @ApiOperation(value = "个人中心-我的玩湃惠民卡-查看详情") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "支付记录id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | |
| | | } |
| | | TPayHuimin tPayHuimin = payHuiminService.getById(id); |
| | | if (tPayHuimin == null) { |
| | | return ResultUtil.error("惠民卡不存在"); |
| | | return ResultUtil.error("玩湃惠民卡不存在"); |
| | | } |
| | | THuiminCard byId = huiminCardService.getById(tPayHuimin.getCardId()); |
| | | MyHuiminCardDetailVO myHuiminCardDetailVO = new MyHuiminCardDetailVO(); |
| | |
| | | } |
| | | } |
| | | |
| | | String temp = "{\"id\":"+tPayHuimin.getId() + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tPayHuimin.getStudentId() + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}"; |
| | | String temp = "{\"id\":"+tPayHuimin.getId() + ","+"\"sid\":" + sid.toJSONString() + "," + "\"rid\":" + rid + "," + "\"uid\":\"" + tPayHuimin.getStudentId().split(",")[0] + "\"," + "\"time\":" + jsonArray.toJSONString() + ",\"type\":" + 2 + "}"; |
| | | myHuiminCardDetailVO.setQrCode(temp); |
| | | myHuiminCardDetailVO.setCardId(tPayHuimin.getCardId()); |
| | | myHuiminCardDetailVO.setHuiminCard(byId); |