pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWebchatLogonStateMapper.java
File was deleted pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWebchatLogonState.java
File was deleted pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/DistrictLevel.java
@@ -15,6 +15,7 @@ */ public enum DistrictLevel implements IEnum { Province((byte)0, "省"), City((byte)1, "市"), County((byte)2, "县"), Town((byte)3, "镇"), @@ -52,7 +53,9 @@ } public static DistrictLevel get(Byte code){ if(code.byteValue() == City.code.byteValue()){ if(code.byteValue() == Province.code.byteValue()) { return Province; }else if(code.byteValue() == City.code.byteValue()){ return City ; }else if(code.byteValue() == County.code.byteValue()){ return County ; pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
@@ -5,8 +5,8 @@ #name: ym type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://192.168.91.73:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull # url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull username: root password: dysql,;.abc!@# druid: pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeOpenIdMapper.xml
@@ -99,4 +99,5 @@ create_time = #{createTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=BIGINT} </update> </mapper> pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWebchatLogonStateMapper.xml
File was deleted pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/district/DistrictCtrl.java
@@ -30,19 +30,20 @@ @Slf4j @Tag(name = "行政区划管理", description = "行政区划增删改查等操作") @RestController @RequestMapping(path="district") @RequestMapping(path = "district") @SuppressWarnings("unchecked")//java版本越高,对泛型约束越严,所以配置SuppressWarnings("unchecked") public class DistrictCtrl { private DistrictSv sv ; private DistrictSv sv; @Autowired private void setSv(DistrictSv sv){ this.sv = sv ; private void setSv(DistrictSv sv) { this.sv = sv; } /** * 客户端请求得到所有行政区划级别数据 * * @return 所有行政区划级别数据 */ @Operation(summary = "行政区划级别", description = "返回所有行政区划级别数据") @@ -55,13 +56,14 @@ ) }) @GetMapping(path = "allLevel") public BaseResponse<List<DistrictLevel>> allDistrictLevels(){ public BaseResponse<List<DistrictLevel>> allDistrictLevels() { //List<DistrictLevel> list = Arrays.asList(DistrictLevel.City, DistrictLevel.County, DistrictLevel.Town, DistrictLevel.Village) ; return BaseResponseUtils.buildSuccess(DistrictLevel.LevelList); } /** * 客户端请求得到所有行政区数据 * * @return 所有行政区数据 */ @Operation(summary = "获得所有行政区", description = "返回所有行政区数据") @@ -75,13 +77,14 @@ }) @GetMapping(path = "all") @SsoAop() public BaseResponse<List<BaDistrict>> all(){ List<BaDistrict> list = this.sv.selectAllByLevel(DistrictLevel.City.code) ; public BaseResponse<List<BaDistrict>> all() { List<BaDistrict> list = this.sv.selectAllByLevel(DistrictLevel.City.code); return BaseResponseUtils.buildSuccess(list); } /** * 得到一个行政区数据 * * @return 一个行政区数据 */ @Operation(summary = "一个行政区", description = "得到一个行政区数据") @@ -95,12 +98,13 @@ }) @GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE) @SsoAop() public BaseResponse<BaDistrict> one(Long id){ public BaseResponse<BaDistrict> one(Long id) { return BaseResponseUtils.buildSuccess(this.sv.selectById(id)); } /** * 保存行政区 * * @param vo 保存行政区form表单对象 * @return 是否成功 */ @@ -115,34 +119,35 @@ }) @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> save(@RequestBody @Valid DistrictVo vo, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ public BaseResponse<Boolean> save(@RequestBody @Valid DistrictVo vo, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } BaDistrict po = DistrictVoMapper.INSTANCT.convert(vo); int count; try { BaDistrict supperPo = this.sv.selectById(po.supperId) ; if(supperPo == null){ return BaseResponseUtils.buildFail("出错,未得到上级行政区") ; }else{ BaDistrict supperPo = this.sv.selectById(po.supperId); if (supperPo == null) { return BaseResponseUtils.buildFail("出错,未得到上级行政区"); } else { po.level = DistrictLevel.get((byte)(supperPo.level.code + 1)) ; } po.deleted = Deleted.NO ; po.deleted = Deleted.NO; count = this.sv.save(po); } catch (Exception e) { log.error("保存行政区异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; return BaseResponseUtils.buildException(e.getMessage()); } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 编辑修改行政区 * * @param vo 保存行政区form表单对象 * @return 是否成功 */ @@ -157,8 +162,8 @@ }) @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() public BaseResponse<Boolean> update(@RequestBody @Valid DistrictVo vo, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ public BaseResponse<Boolean> update(@RequestBody @Valid DistrictVo vo, BindingResult bindingResult) { if (bindingResult != null && bindingResult.hasErrors()) { return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } BaDistrict po = DistrictVoMapper.INSTANCT.convert(vo); @@ -167,18 +172,19 @@ count = this.sv.update(po); } catch (Exception e) { log.error("保存行政区异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; return BaseResponseUtils.buildException(e.getMessage()); } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 删除行政区 * * @param id 行政区ID * @return 是否成功 */ @@ -191,28 +197,29 @@ schema = @Schema(implementation = Boolean.class))} ) }) @GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE) @GetMapping(path = "delete") @SsoAop() public BaseResponse<Boolean> delete(Long id){ if(id == null){ return BaseResponseUtils.buildFail("id不能为空") ; public BaseResponse<Boolean> delete(Long id) { if (id == null) { return BaseResponseUtils.buildFail("id不能为空"); } int count; try { count = this.sv.delete(id); } catch (Exception e) { log.error("保存行政区异常", e); return BaseResponseUtils.buildException(e.getMessage()) ; return BaseResponseUtils.buildException(e.getMessage()); } if(count <= 0){ return BaseResponseUtils.buildFail("数据库存储失败") ; }else{ return BaseResponseUtils.buildSuccess(true) ; if (count <= 0) { return BaseResponseUtils.buildFail("数据库存储失败"); } else { return BaseResponseUtils.buildSuccess(true); } } /** * 根据级别获取行政区划列表 * * @param id * @return */ @@ -227,20 +234,21 @@ }) @GetMapping(path = "/level/{id}") @SsoAop() public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getDistrictgsByLevel(@PathVariable("id") Integer id){ if(id == null || id <= 0){ return BaseResponseUtils.buildFail("id不能为空") ; public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getDistrictgsByLevel(@PathVariable("id") Integer id) { if (id == null || id <= 0) { return BaseResponseUtils.buildFail("id不能为空"); } List<Map<String, Object>> map_Districts = Optional.ofNullable(sv.getDistrictgsByLevel(id)).orElse(new ArrayList<>()); if(map_Districts == null || map_Districts.size() == 0) { return BaseResponseUtils.buildFail("您输入的层级有误") ; if (map_Districts == null || map_Districts.size() == 0) { return BaseResponseUtils.buildFail("您输入的层级有误"); } return BaseResponseUtils.buildSuccess(map_Districts); } /** * 根据父ID获取行政区划列表 * * @param supperId * @return */ @@ -255,20 +263,21 @@ }) @GetMapping(path = "/supperid/{supperId}") @SsoAop() public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getDistrictsBySupperId(@PathVariable("supperId") Long supperId){ if(supperId == null || supperId <= 0){ return BaseResponseUtils.buildFail("父ID不能为空") ; public BaseResponse<QueryResultVo<List<Map<String, Object>>>> getDistrictsBySupperId(@PathVariable("supperId") Long supperId) { if (supperId == null || supperId <= 0) { return BaseResponseUtils.buildFail("父ID不能为空"); } List<Map<String, Object>> map_Districts = Optional.ofNullable(sv.getDistrictsBySupperId(supperId)).orElse(new ArrayList<>()); if(map_Districts == null || map_Districts.size() == 0) { return BaseResponseUtils.buildFail("您输入的父级ID有误") ; if (map_Districts == null || map_Districts.size() == 0) { return BaseResponseUtils.buildFail("您输入的父级ID有误"); } return BaseResponseUtils.buildSuccess(map_Districts); } /** * 获取三级行政区划 * * @return 县镇村三级行政区划 */ @GetMapping(path = "/three") @@ -279,35 +288,35 @@ JSONArray array_villages = new JSONArray(); List<Map<String, Object>> list_counties = Optional.ofNullable(sv.getDistrictgsByLevel(2)).orElse(new ArrayList<>()); if(list_counties.size() > 0) { if (list_counties.size() > 0) { array_counties = JSONArray.parseArray(JSON.toJSONString(list_counties)); // 遍历每一个县,将县下的镇村加到县的子集 for(int i = 0; i < array_counties.size(); i++) { for (int i = 0; i < array_counties.size(); i++) { JSONObject job_county = array_counties.getJSONObject(i); Long countyId = job_county.getLong("id"); List<Map<String, Object>> list_towns = Optional.ofNullable(sv.getDistrictsBySupperId(countyId)).orElse(new ArrayList<>()); if(list_towns.size() > 0) { array_towns = JSONArray.parseArray(JSON.toJSONString(list_towns)); // 遍历每一个镇,将镇下村列表加到镇的子集 for(int j = 0; j < array_towns.size(); j++) { JSONObject job_town = array_towns.getJSONObject(j); Long townId = job_town.getLong("id"); List<Map<String, Object>> list_villages = Optional.ofNullable(sv.getDistrictsBySupperId(townId)).orElse(new ArrayList<>()); if(list_villages.size() > 0) { array_villages = JSONArray.parseArray(JSON.toJSONString(list_villages)); job_town.put("children", array_villages); } Long countyId = job_county.getLong("id"); List<Map<String, Object>> list_towns = Optional.ofNullable(sv.getDistrictsBySupperId(countyId)).orElse(new ArrayList<>()); if (list_towns.size() > 0) { array_towns = JSONArray.parseArray(JSON.toJSONString(list_towns)); // 遍历每一个镇,将镇下村列表加到镇的子集 for (int j = 0; j < array_towns.size(); j++) { JSONObject job_town = array_towns.getJSONObject(j); Long townId = job_town.getLong("id"); List<Map<String, Object>> list_villages = Optional.ofNullable(sv.getDistrictsBySupperId(townId)).orElse(new ArrayList<>()); if (list_villages.size() > 0) { array_villages = JSONArray.parseArray(JSON.toJSONString(list_villages)); job_town.put("children", array_villages); } //System.out.println("----" + array_towns); } // 镇村组装完毕,将镇村加到县下 job_county.put("children", array_towns); //System.out.println("----" + array_towns); } // 镇村组装完毕,将镇村加到县下 job_county.put("children", array_towns); } // 县组装完毕 //String a = array_counties.toJSONString(); //System.out.println(a); return BaseResponseUtils.buildSuccess(array_counties); }else { } else { return BaseResponseUtils.buildFail("县级行政区划不存在"); } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
@@ -213,13 +213,15 @@ @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> update(@RequestBody @Valid PrDivide po, BindingResult bindingResult){ public BaseResponse<Boolean> update(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 接收村编号(主键) Long villageId = po.getVillageid(); Long villageId = po.getVillageId(); PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po); if (villageId!=null){ /** @@ -231,14 +233,14 @@ } Long countryId = Long.parseLong(map_districts.get("countryId").toString()); Long townId = Long.parseLong(map_districts.get("townId").toString()); po.setCountyid(countryId); po.setTownid(townId); prDivide.setCountyid(countryId); prDivide.setTownid(townId); } Date operateTime = new Date(); po.setOperatedt(operateTime); prDivide.setOperatedt(operateTime); Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(po)).orElse(0); Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(prDivide)).orElse(0); if(rec == 0) { return BaseResponseUtils.buildFail("分水房修改失败"); } pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DtoDivide.java
@@ -18,6 +18,8 @@ public class DtoDivide { public static final long serialVersionUID = 1L; @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED) private Long id; /** * 所在村 */ pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DtoToDividePojo.java
@@ -16,6 +16,7 @@ public interface DtoToDividePojo { DtoToDividePojo INSTANCT = Mappers.getMapper(DtoToDividePojo.class); @Mapping(target = "id", source = "id") @Mapping(target = "villageid", source = "villageId") @Mapping(target = "blockid", source = "blockId") @Mapping(target = "name", source = "name") pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/activeCard/ActiveCardCtrl.java
@@ -5,6 +5,7 @@ import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrGlobal.daoBa.BaSettingsMapper; import com.dy.pipIrrGlobal.pojoSe.SeActiveCard; import com.dy.pipIrrGlobal.pojoSe.SeClientCard; import com.dy.pipIrrGlobal.util.Constant; @@ -50,6 +51,7 @@ private final ClientCardSv clientCardSv; private final RechargeCtrl rechargeCtrl; private final RechargeSv rechargeSv; private final BaSettingsMapper baSettingsMapper; //@Value("${projectCode.ym}") @@ -232,8 +234,11 @@ }else { map.put("orderNumber",rec+"");//返回开卡ID } //map.put("projectCode", projectCode); map.put("projectCode", Constant.projectCode_ym); String projectNo = baSettingsMapper.getItemValue("projectNo"); Integer projectNo1 = Integer.valueOf(projectNo); String projectNo3 = String.format("%02x", projectNo1); map.put("projectNo", projectNo3); //map.put("projectCode", Constant.projectCode_ym); map.put("cardNum", cardNum); return BaseResponseUtils.buildSuccess(map) ; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/recharge/RechargeCtrl.java
@@ -188,7 +188,8 @@ if(rec_history == 0) { return BaseResponseUtils.buildFail(SellResultCode.RECHARGE_FAIL_WRITE_RECHARGE_HISTORY_ERROR.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; Map returnMap = new HashMap(); returnMap.put("orderNumber",rec+"");//返回充值ID return BaseResponseUtils.buildSuccess(returnMap) ; } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/util/PayHelper.java
@@ -269,6 +269,7 @@ Map<String, String> headers = new HashMap<>(); headers.put("Authorization", header); headers.put("Accept", "application/json"); //headers.put("User-Agent", "https://zh.wikipedia.org/wiki/User_agent"); JSONObject job_result = restTemplateUtil.getHeaders(PayInfo.certificates,null, headers); JSONObject job_headers = job_result.getJSONObject("headers"); pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/virtualCard/VirtualCardSv.java
@@ -155,6 +155,15 @@ } /** * 根据订单号获取虚拟卡充值对象 * @param orderNumber * @return */ public SeVcRecharge getVCRechargeByorderNumber(String orderNumber) { return seVcRechargeMapper.getVCRechargeByorderNumber(orderNumber); } /** * 修改虚拟卡充值记录 * 微信支付通知后: * 1. 更新充值表:充值后余额、支付完成时间、订单状态 pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PayInfo.java
@@ -42,7 +42,7 @@ * 支付结果通知API */ //public static String notifyUrl = "https://www.muxiaobao.com/api/Payment/OrderNotify"; public static String notifyUrl = "https://44978f7456.imdo.co/webchat/payment/orderNotify"; public static String notifyUrl = "https://44978f7456.imdo.co/sell/payment/orderNotify"; /* * 查询订单API pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PaymentCtrl.java
@@ -1,5 +1,6 @@ package com.dy.pipIrrSell.wechatpay; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; @@ -17,8 +18,8 @@ import com.dy.pipIrrSell.virtualCard.enums.LastOperateENUM; import com.dy.pipIrrSell.virtualCard.enums.RefundItemStateENUM; import com.dy.pipIrrSell.wallet.enums.RefundStatusENUM; import com.dy.pipIrrSell.wechatpay.dto.Code2Session; import com.dy.pipIrrSell.wechatpay.dto.DtoOrder; import com.dy.pipIrrSell.wechatpay.dto.NotifyResource; import com.dy.pipIrrSell.wechatpay.dto.OrderNotify; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -26,6 +27,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -37,6 +39,7 @@ import org.springframework.web.bind.annotation.*; import javax.crypto.NoSuchPaddingException; import java.io.BufferedReader; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.InvalidKeyException; @@ -80,60 +83,6 @@ // 平台证书公钥 private final Map CERTIFICATE_MAP = new HashMap(); /** * 登录凭证校验 * @param code2Session 登录凭证校验传入对象 * @param bindingResult * @return * @throws Exception */ @Operation(summary = "登录凭证校验", description = "登录凭证校验") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @PostMapping(path = "getSessionId") @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<Boolean> getSessionId(@RequestBody @Valid Code2Session code2Session, BindingResult bindingResult) throws Exception { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } Map<String, Object> queryParams = new HashMap<>(); queryParams.put("appid", appid); queryParams.put("secret", code2Session.getSecret()); queryParams.put("js_code", code2Session.getJs_code()); queryParams.put("grant_type", grantType); Map<String, String> headerParams = new HashMap<>(); JSONObject job = restTemplateUtil.get(loginUrl, queryParams, headerParams); if(job.getLong("errcode") != null && job.getLong("errcode") >= -1) { return BaseResponseUtils.buildFail("登录凭证校验失败"); } String openid = job.getString("openid"); String sessionKey = job.getString("session_key"); // 添加登录态记录 SeWebchatLogonState po = new SeWebchatLogonState(); po.setOpenId(openid); po.setSessionKey(sessionKey); Date createTime = new Date(); po.setCreateTime(createTime); Long id = paymentSv.insert(po); if(id == null || id <= 0) { return BaseResponseUtils.buildFail("登录态记录添加失败"); } String SessionId = String.valueOf(id); return BaseResponseUtils.buildSuccess(SessionId) ; } /** * 下载微信支付平台证书 测试完废除 @@ -203,14 +152,12 @@ if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 接收参数:登录态ID、农户ID、虚拟卡ID、充值金额 // 接收参数:登录态ID、虚拟卡ID、充值金额(分) Long sessionId = order.getSessionId(); Long virtualId = order.getVirtualId(); Long virtualId = order.getVcId(); Integer rechargeAmount = order.getRechargeAmount(); String prepayId = ""; //SeWebchatLogonState po = paymentSv.selectOne(Long.parseLong(sessionId)); //String openid = po.getOpenId(); SeOpenId po = paymentSv.selectOne(sessionId); String openid = po.getOpenId(); @@ -245,7 +192,7 @@ //订单金额 JSONObject job_amount = new JSONObject(); job_amount.put("total", 1); job_amount.put("total", rechargeAmount); job_amount.put("currency", "CNY"); job_body.put("amount", job_amount); @@ -278,9 +225,47 @@ } /** * 再次签名 * @param prepayId 预支付交易会话标识 * @return 小程序调起支付参数 * @throws Exception */ @Operation(summary = "再次签名", description = "再次签名") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @GetMapping(path = "/signAgain") @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<JSONObject> signAgain(@RequestParam("prepayId") String prepayId) throws Exception { // 获取随机串和时间戳,放在此处以保证 String appid = PayInfo.appid; String timeStamp = String.valueOf(System.currentTimeMillis() / 1000); String nonceStr = payHelper.generateRandomString(); String pkg = "prepay_id=" + prepayId; String message = payHelper.buildMessage_signAgain(appid, timeStamp, nonceStr, pkg); String paySign = payHelper.sign(message.getBytes("utf-8"), privateCertFileName); JSONObject job_result = new JSONObject(); job_result.put("timeStamp", timeStamp); job_result.put("nonceStr", nonceStr); job_result.put("package", pkg); job_result.put("signType", signType); job_result.put("paySign", paySign); return BaseResponseUtils.buildSuccess(job_result) ; } /** * 支付通知/退款结果通知 * @param headers * @param orderNotify * @param request * @param response * @return * @throws IOException @@ -298,12 +283,12 @@ @PostMapping(path = "orderNotify", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() public JSONObject orderNotify(@RequestHeader HttpHeaders headers, @RequestBody OrderNotify orderNotify, HttpServletResponse response) throws IOException, GeneralSecurityException { public JSONObject orderNotify(@RequestHeader HttpHeaders headers, HttpServletRequest request, HttpServletResponse response) throws IOException, GeneralSecurityException { JSONObject result = new JSONObject(); /** * 1.验签处理 * 从header中取出4个子参数,同时取出body * 从header中取出4个子参数 * 验时间差,超过5分钟的不处理 * 验证签名 * 验证书序列号,必须与某一个证书的序列号一致 @@ -312,7 +297,18 @@ String wechatpaySerial = String.valueOf(headers.get("Wechatpay-Serial").get(0)); String wechatpaySignature = String.valueOf(headers.get("Wechatpay-Signature").get(0)); String wechatpayTimestamp = String.valueOf(headers.get("Wechatpay-Timestamp").get(0)); String bodyStr = JSONObject.toJSONString(orderNotify); // 获取body内容 BufferedReader reader = request.getReader(); StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { stringBuilder.append(line); } String bodyStr = stringBuilder.toString(); // body转对象 OrderNotify orderNotify = JSON.parseObject(bodyStr, OrderNotify.class); // 验时间戳,时间差大于5分钟的拒绝 Long timeDiff = (System.currentTimeMillis() / 1000 - Long.parseLong(wechatpayTimestamp))/60; @@ -348,10 +344,7 @@ return result; } /** * 解密处理 * 1 */ // 解密处理 String eventType = orderNotify.getEvent_type(); if(eventType != null && eventType.equals("TRANSACTION.SUCCESS")) { @@ -361,7 +354,7 @@ * 取出通知数据对象,继而取出解密所需的associatedData和nonce,以及密文ciphertext * 解密ciphertext得到 */ OrderNotify.NotifyResource notifyResource = orderNotify.getResource(); NotifyResource notifyResource = orderNotify.getResource(); String associatedData = notifyResource.getAssociated_data(); String nonce = notifyResource.getNonce(); String ciphertext = notifyResource.getCiphertext(); @@ -369,19 +362,22 @@ String resource = AesUtil.decryptToString(PayInfo.key.getBytes("utf-8"), associatedData.getBytes("utf-8"), nonce.getBytes("utf-8"), ciphertext); JSONObject job_resource = JSONObject.parseObject(resource); // 解密后取出:商户订单员、微信支付订单号、交易状态、支付完成时间 // 解密后取出:商户订单号、微信支付订单号、交易状态、支付完成时间 String out_trade_no = job_resource.getString("out_trade_no"); String transaction_id = job_resource.getString("transaction_id"); String trade_state = job_resource.getString("trade_state"); Date success_time = job_resource.getDate("success_time"); // 更新虚拟卡表及充值表响应字段 BaseResponse result_ = virtualCardSv.updateVCRecharge(out_trade_no, success_time); if(!result_.getCode().equals("0001")) { response.setStatus(500); result.put("code", "FAIL"); result.put("message", "失败"); return result; // 如果当前订单状态为未支付状态,则更新虚拟卡表及充值表响应字段 SeVcRecharge seVcRecharge = virtualCardSv.getVCRechargeByorderNumber(out_trade_no); if(seVcRecharge != null && seVcRecharge.getOrderState() == 1) { BaseResponse result_ = virtualCardSv.updateVCRecharge(out_trade_no, success_time); if(!result_.getCode().equals("0001")) { response.setStatus(500); result.put("code", "FAIL"); result.put("message", "失败"); return result; } } } else if(eventType != null && eventType.equals("REFUND.SUCCESS")) { // 退款成功后回调 @@ -390,7 +386,7 @@ * 取出通知数据对象,继而取出解密所需的associatedData和nonce,以及密文ciphertext * 解密ciphertext得到 */ OrderNotify.NotifyResource notifyResource = orderNotify.getResource(); NotifyResource notifyResource = orderNotify.getResource(); String associatedData = notifyResource.getAssociated_data(); String nonce = notifyResource.getNonce(); String ciphertext = notifyResource.getCiphertext(); @@ -454,43 +450,5 @@ result.put("code", "SUCCESS"); result.put("message", "成功"); return result; } /** * 再次签名 * @param prepayId 预支付交易会话标识 * @return 小程序调起支付参数 * @throws Exception */ @Operation(summary = "再次签名", description = "再次签名") @ApiResponses(value = { @ApiResponse( responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, description = "操作结果:true:成功,false:失败(BaseResponse.content)", content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = Boolean.class))} ) }) @GetMapping(path = "/signAgain") @Transactional(rollbackFor = Exception.class) @SsoAop() public BaseResponse<JSONObject> signAgain(@RequestParam("prepayId") String prepayId) throws Exception { // 获取随机串和时间戳,放在此处以保证 String appid = PayInfo.appid; String timestamp = String.valueOf(System.currentTimeMillis() / 1000); String nonceStr = payHelper.generateRandomString(); String pkg = "prepay_id=" + prepayId; String message = payHelper.buildMessage_signAgain(appid, timestamp, nonceStr, pkg); String paySign = payHelper.sign(message.getBytes("utf-8"), privateCertFileName); JSONObject job_result = new JSONObject(); job_result.put("timestamp", timestamp); job_result.put("nonceStr", nonceStr); job_result.put("package", pkg); job_result.put("signType", signType); job_result.put("paySign", paySign); return BaseResponseUtils.buildSuccess(job_result) ; } } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PaymentSv.java
@@ -2,10 +2,8 @@ import com.dy.pipIrrGlobal.daoSe.SeOpenIdMapper; import com.dy.pipIrrGlobal.daoSe.SeVcRechargeMapper; import com.dy.pipIrrGlobal.daoSe.SeWebchatLogonStateMapper; import com.dy.pipIrrGlobal.pojoSe.SeOpenId; import com.dy.pipIrrGlobal.pojoSe.SeVcRecharge; import com.dy.pipIrrGlobal.pojoSe.SeWebchatLogonState; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -21,33 +19,16 @@ @Service public class PaymentSv { @Autowired private SeWebchatLogonStateMapper seWebchatLogonStateMapper; @Autowired private SeVcRechargeMapper seVcRechargeMapper; @Autowired private SeOpenIdMapper seOpenIdMapper; /** * 添加登录态状态记录 * @param po * @return */ Long insert(SeWebchatLogonState po) { seWebchatLogonStateMapper.insert(po); return po.getId(); } /** * 根据登录态ID获取登录态对象 * @param id * @param sessionId * @return */ SeWebchatLogonState selectOne2(Long id) { return seWebchatLogonStateMapper.selectByPrimaryKey(id); } SeOpenId selectOne(Long sessionId) { return seOpenIdMapper.selectByPrimaryKey(sessionId); } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/dto/DtoOrder.java
@@ -24,11 +24,11 @@ private Long sessionId; /** * 虚拟卡编号,外键,用来获取虚拟卡余额 * 虚拟卡ID,用来获取虚拟卡余额 */ @Schema(description = "虚拟卡编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @NotNull(message = "虚拟卡编号不能为空") private Long virtualId; @NotNull(message = "虚拟卡ID不能为空") private Long vcId; /** * 充值金额金额 pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/dto/NotifyResource.java
New file @@ -0,0 +1,40 @@ package com.dy.pipIrrSell.wechatpay.dto; import lombok.Data; /** * @author ZhuBaoMin * @date 2024-06-13 19:16 * @LastEditTime 2024-06-13 19:16 * @Description */ @Data public class NotifyResource { /** * 原始类型 * 原始回调类型为:transaction */ private String original_type; /** * 加密算法类型 * 仅支持AEAD_AES_256_GCM */ private String algorithm; /** * 数据密文 */ private String ciphertext; /** * 附加数据 */ public String associated_data; /** * 随机串 */ private String nonce; } pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/dto/OrderNotify.java
@@ -48,34 +48,34 @@ private String summary; @Data public class NotifyResource { /** * 加密算法类型 * 仅支持AEAD_AES_256_GCM */ private String algorithm; /** * 数据密文 */ private String ciphertext; /** * 附加数据 */ public String associated_data; /** * 原始类型 * 原始回调类型为:transaction */ private String original_type; /** * 随机串 */ private String nonce; } //@Data //public class NotifyResource { // // /** // * 加密算法类型 // * 仅支持AEAD_AES_256_GCM // */ // private String algorithm; // // /** // * 数据密文 // */ // private String ciphertext; // // /** // * 附加数据 // */ // public String associated_data; // // /** // * 原始类型 // * 原始回调类型为:transaction // */ // private String original_type; // // /** // * 随机串 // */ // private String nonce; //} }