| | |
| | | import com.ruoyi.admin.utils.util.HttpRequester; |
| | | import com.ruoyi.admin.utils.util.HttpRespons; |
| | | import com.ruoyi.admin.utils.util.Md5_Sign; |
| | | import com.ruoyi.admin.vo.InfoDto; |
| | | import com.ruoyi.admin.vo.MoneyRecentQuery; |
| | | import com.ruoyi.admin.vo.PayDto; |
| | | import com.ruoyi.admin.vo.RencentBalance; |
| | | import com.ruoyi.admin.vo.*; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | |
| | | |
| | | |
| | | TFranchiseeBalanceChange tFranchiseeBalanceChange = new TFranchiseeBalanceChange(); |
| | | tFranchiseeBalanceChange.setAmount(money); |
| | | tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | tFranchiseeBalanceChange.setIs_pay(0); |
| | | tFranchiseeBalanceChange.setFranchiseeName(byId.getName()); |
| | | tFranchiseeBalanceChange.setFranchiseeId(String.valueOf(byId.getId())); |
| | |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private NativePayService nativePayService; |
| | | |
| | | public static void main(String[] args) { |
| | | BigDecimal money = new BigDecimal(2); |
| | | |
| | | |
| | | System.err.println(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | |
| | | @ApiOperation(value = "扫码支付",tags = {"后台2.0-加盟商列表余额"}) |
| | | @PostMapping(value = "/code/buy") |
| | |
| | | // com.wechat.pay.java.service.payments.nativepay.model.PrepayResponse prepay = nativePayService.prepay(prepayRequest); |
| | | //预支付成功,创建预支付订单 |
| | | TFranchiseeBalanceChange tFranchiseeBalanceChange = new TFranchiseeBalanceChange(); |
| | | tFranchiseeBalanceChange.setAmount(money); |
| | | tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | tFranchiseeBalanceChange.setIs_pay(0); |
| | | tFranchiseeBalanceChange.setFranchiseeName(byId.getName()); |
| | | tFranchiseeBalanceChange.setFranchiseeId(String.valueOf(byId.getId())); |
| | | tFranchiseeBalanceChange.setType(2); |
| | | tFranchiseeBalanceChange.setCode(code); |
| | | tFranchiseeBalanceChange.setRemark("加盟商扫码充值"); |
| | | balanceChangeService.save(tFranchiseeBalanceChange); |
| | | |
| | | |
| | | |
| | | PayDto payDto = new PayDto(); |
| | | payDto.setOrderId(tFranchiseeBalanceChange.getId()); |
| | | payDto.setQrCode(rcResult); |
| | | |
| | | return R.ok(payDto); |
| | | } catch (HttpException e) { // 发送HTTP请求失败 |
| | | // log.error("发送HTTP请求失败: {}", e.getHttpRequest()); |
| | | } catch (ServiceException e) { // 服务返回状态小于200或大于等于300,例如500 |
| | | // log.error("服务返回状态异常: {}", e.getResponseBody()); |
| | | } catch (MalformedMessageException e) { // 服务返回成功,返回体类型不合法,或者解析返回体失败 |
| | | // log.error("返回体类型不合法: {}", e.getMessage()); |
| | | } catch (Exception e) { |
| | | // log.error("预下单异常: {}", e.getMessage()); |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | @ApiOperation(value = "扫码支付",tags = {"后台2.0-总平台"}) |
| | | @PostMapping(value = "/code/buyPlatform") |
| | | public R buyPlatform(@RequestParam BigDecimal money,Integer id) throws AlipayApiException, IOException { |
| | | Franchisee byId = franchiseeService.getById(id); |
| | | String code = generateTradeNumber(); |
| | | int i = money.multiply(BigDecimal.valueOf(100)).intValue(); |
| | | String key = "ad273ceb5e1b49e68d5c565d28d1d305";/** md5密钥商户后台-商户中心-商户设置-密钥管理获取 必填!*/ |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("p0_Version", "2.5");/** 版本号 */ |
| | | map.put("p1_MerchantNo", "888122400007793");/** 商户编号 */ |
| | | map.put("p2_OrderNo", code); /**商户订单号*/ |
| | | map.put("p3_Amount", String.valueOf(money));/**订单金额*/ |
| | | map.put("p4_Cur", "1"); /**交易币种 */ |
| | | map.put("p5_ProductName", "充值"); /** 商品名称 */ |
| | | map.put("p6_ProductDesc", "加盟商充值"); /** 商品名称 */ |
| | | // map.put("p7_Mp", ""); /** 如果商户请求时传递了该参数,则返回给商户时会原值传 回。 */ |
| | | map.put("p9_NotifyUrl", "http://101.34.55.62:9100/admin/franchisee/callBack"); /** 服务器异步通知地址 */ |
| | | map.put("q1_FrpCode", "WEIXIN_NATIVE"); /** 微信扫码(主扫)【注:此为用户主扫,商户被扫】*/ |
| | | map.put("q4_IsShowPic", "1"); /** 是否展示二 维码图片 1表示输出*/ |
| | | map.put("q7_AppId", "wx1a4a7760be53a835"); /** 交易类型*/ |
| | | map.put("qa_TradeMerchantNo", "777165000859101"); /** 777开头的报备商户号 必填!*/ |
| | | map.put("qi_FqSellerPercen", "0"); /** 卖家承担收 费比例 目前仅支持传入 0 ,即用户承 担手续费!*/ |
| | | |
| | | String Strmap = CreateLinkStringByGet1.createLinkStringByGet(map); |
| | | |
| | | // 签名 |
| | | String sign = ""; |
| | | sign = Md5_Sign.SignByMD5(Strmap, key); |
| | | map.put("hmac", sign);/** 签名数据 */ |
| | | System.out.println("发送:" + JSON.toJSONString(map).toString()); |
| | | |
| | | // post请求参数内容 |
| | | HttpRequester hr = new HttpRequester(); |
| | | HttpRespons HP = hr.sendPost("https://trade.joinpay.com/tradeRt/uniPay", map); |
| | | System.out.println("接收返回参数:" + HP.getContent()); |
| | | JSONObject jsonObject = JSONObject.parseObject(HP.getContent()); |
| | | String rcResult = jsonObject.getString("rd_Pic"); |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("rcResult", rcResult); |
| | | // com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest prepayRequest = new com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest(); |
| | | // prepayRequest.setAppid(weChatConfig.appId); |
| | | // prepayRequest.setMchid(weChatConfig.merchantId); |
| | | // prepayRequest.setOutTradeNo(code); |
| | | // prepayRequest.setDescription("购买资料"); |
| | | // prepayRequest.setNotifyUrl("http://www.zhipingwang.com.cn:9090/admin/franchisee/callBack"); |
| | | // com.wechat.pay.java.service.payments.nativepay.model.Amount amount = new com.wechat.pay.java.service.payments.nativepay.model.Amount(); |
| | | // amount.setTotal(i); |
| | | // prepayRequest.setAmount(amount); |
| | | // // 调用下单方法,得到应答 |
| | | // com.wechat.pay.java.service.partnerpayments.app.model.PrepayResponse response; |
| | | try { |
| | | // com.wechat.pay.java.service.payments.nativepay.model.PrepayResponse prepay = nativePayService.prepay(prepayRequest); |
| | | //预支付成功,创建预支付订单 |
| | | TFranchiseeBalanceChange tFranchiseeBalanceChange = new TFranchiseeBalanceChange(); |
| | | tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | tFranchiseeBalanceChange.setIs_pay(0); |
| | | tFranchiseeBalanceChange.setFranchiseeName(byId.getName()); |
| | | tFranchiseeBalanceChange.setFranchiseeId(String.valueOf(byId.getId())); |
| | |
| | | System.err.println("======回调开始"+r2_OrderNo); |
| | | System.err.println("请求"+request.getParameterMap()); |
| | | Map<String, String[]> parameterMap = request.getParameterMap(); |
| | | // 2.0新增充值费率 |
| | | String r6Status = request.getParameter("r6_Status"); |
| | | if (org.springframework.util.StringUtils.hasLength(r6Status)){ |
| | | if (r6Status.equals("101")){ |
| | |
| | | /** |
| | | * 加盟商信息分页列表 |
| | | * |
| | | * @param pageNum 页码 |
| | | * @param pageSize 每页显示条数 |
| | | */ |
| | | @RequiresPermissions("franchisee_list") |
| | | @ApiOperation(value = "加盟商信息分页查询列表", tags = {"后台-加盟商管理"}) |
| | | @GetMapping(value = "/page") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "加盟商名称", name = "name", dataType = "String"), |
| | | @ApiImplicitParam(value = "管理员", name = "head", dataType = "String"), |
| | | @ApiImplicitParam(value = "手机号码", name = "phone", dataType = "String"), |
| | | @ApiImplicitParam(value = "管辖城市", name = "city", dataType = "String"), |
| | | @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "每页条数", name = "pageSize", dataType = "Integer", required = true) |
| | | }) |
| | | public R<IPage<Franchisee>> queryPageList(String name, String head, String phone, String city, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | @PostMapping(value = "/page") |
| | | public R<IPage<Franchisee>> queryPageList(@RequestBody FranchiseeListDTO dto) { |
| | | LambdaQueryChainWrapper<Franchisee> wrapper = franchiseeService.lambdaQuery(); |
| | | wrapper = StringUtils.isNotBlank(name) ? wrapper.like(Franchisee::getName, name) : wrapper; |
| | | wrapper = StringUtils.isNotBlank(head) ? wrapper.like(Franchisee::getHead, head) : wrapper; |
| | | wrapper = StringUtils.isNotBlank(phone) ? wrapper.like(Franchisee::getHeadPhone, phone) : wrapper; |
| | | wrapper = StringUtils.isNotBlank(city) ? wrapper.like(Franchisee::getCity, city) : wrapper; |
| | | wrapper = StringUtils.isNotBlank(dto.getName()) ? wrapper.like(Franchisee::getName, dto.getName()) : wrapper; |
| | | wrapper = StringUtils.isNotBlank(dto.getHead()) ? wrapper.like(Franchisee::getHead, dto.getHead()) : wrapper; |
| | | wrapper = StringUtils.isNotBlank(dto.getPhone()) ? wrapper.like(Franchisee::getHeadPhone, dto.getPhone()) : wrapper; |
| | | if (org.springframework.util.StringUtils.hasLength(dto.getCity())){ |
| | | String[] cityCodes = dto.getCity().split(","); |
| | | wrapper.and(wrapperLike -> { |
| | | Arrays.stream(cityCodes) |
| | | .forEach(code -> wrapperLike.like(Franchisee::getCityCode, code)); |
| | | }); |
| | | } |
| | | |
| | | Page<Franchisee> page = wrapper.eq(Franchisee::getIsDelete, 0) |
| | | .orderByDesc(Franchisee::getCreateTime).page(Page.of(pageNum, pageSize)); |
| | | .orderByDesc(Franchisee::getCreateTime).page(Page.of(dto.getPageNum(), dto.getPageSize())); |
| | | for (Franchisee record : page.getRecords()) { |
| | | if (record.getSiteIds()!=null){ |
| | | String[] split = record.getSiteIds().split(","); |
| | |
| | | } |
| | | String city = str.substring(Constants.ZERO, str.length() - 1); |
| | | franchisee.setCity(city); |
| | | List<SysUser> list1 = sysUserService.lambdaQuery().eq(SysUser::getAccount, franchisee.getAdminAccount()) |
| | | .eq(SysUser::getIsEnable, 1).eq(SysUser::getIsDelete, 0).list(); |
| | | if(!list1.isEmpty()){ |
| | | return R.passwordError("该管理员账号已存在!"); |
| | | } |
| | | boolean save = franchiseeService.save(franchisee); |
| | | // 生成sysUser账号 |
| | | SysUser sysUser = new SysUser(); |