| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.google.common.collect.ImmutableMap; |
| | | import com.lkl.laop.sdk.exception.SDKException; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.ip.IpUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | |
| | | import com.ruoyi.system.service.TCrmSupplierService; |
| | | import com.ruoyi.system.service.TErpProcurementGoodsService; |
| | | import com.ruoyi.system.service.TErpProcurementService; |
| | | import com.ruoyi.system.task.base.QuartzManager; |
| | | import com.ruoyi.system.task.base.TimeJobType; |
| | | import com.ruoyi.system.task.jobs.RevenueSharingJob; |
| | | import com.ruoyi.web.core.config.LakalaConfig; |
| | | import com.ruoyi.web.listener.event.TradeOrderEvent; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.SneakyThrows; |
| | |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.DefaultHttpClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | private final TCrmSupplierService crmSupplierService; |
| | | |
| | | private final TokenService tokenService; |
| | | |
| | | private final ApplicationContext applicationContext; |
| | | |
| | | @Autowired |
| | | public TOrderController(TErpProcurementService erpProcurementService, TokenService tokenService, TErpProcurementGoodsService erpProcurementGoodsService, TCrmSupplierService crmSupplierService) { |
| | | public TOrderController(TErpProcurementService erpProcurementService, TokenService tokenService, TErpProcurementGoodsService erpProcurementGoodsService, TCrmSupplierService crmSupplierService, ApplicationContext applicationContext) { |
| | | this.erpProcurementService = erpProcurementService; |
| | | this.tokenService = tokenService; |
| | | this.erpProcurementGoodsService = erpProcurementGoodsService; |
| | | this.crmSupplierService = crmSupplierService; |
| | | this.applicationContext = applicationContext; |
| | | } |
| | | |
| | | private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
| | |
| | | @ApiOperation(value = "支付") |
| | | @PostMapping(value = "/payOrder") |
| | | @SneakyThrows |
| | | @Log(title = "采购管理-支付", businessType = BusinessType.UPDATE) |
| | | public R<?> payOrder(@RequestParam String id, String type, HttpServletRequest request) { |
| | | try { |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | String apiPath = "sit/api/v3/labs/trans/preorder"; |
| | | String apiPath = "api/v3/labs/trans/preorder"; |
| | | String body = "{\n" + |
| | | "\t\"req_time\": \"" + time + "\",\n" + |
| | | "\t\"version\": \"3.0\",\n" + |
| | |
| | | "\t\t\"out_trade_no\": \"" + outTradeNo + "\",\n" + |
| | | "\t\t\"merchant_no\": \""+supplier.getRecvMerchantNo()+"\",\n" + |
| | | "\t\t\"term_no\": \""+supplier.getTermNo()+"\",\n" + |
| | | "\t\t\"notify_url\": \"http://221.182.45.100:8089/t-sys-order/messageHandle\",\n" + |
| | | "\t\t\"notify_url\": \"https://haizhentong.com/manage/t-sys-order/messageHandle\",\n" + |
| | | "\t\t\"location_info\": {\n" + |
| | | "\t\t\t\"request_ip\": \"" + ipAddr + "\"\n" + |
| | | "\t\t},\n" + |
| | |
| | | |
| | | |
| | | // 操作分账 |
| | | HttpRequest post = HttpUtil.createPost(LakalaConfig.getServerUrl() + "sit/api/v3/sacs/separate"); |
| | | HttpRequest post = HttpUtil.createPost(LakalaConfig.getServerUrl() + "api/v3/sacs/separate"); |
| | | |
| | | HashMap<String, Object> reqMap = new HashMap<>(); |
| | | reqMap.put("version", "3.0"); |
| | |
| | | map.put("log_no", erpProcurement.getPayTransactionId()); |
| | | map.put("log_date", DateUtils.dateTime()); |
| | | map.put("cal_type", "0"); |
| | | map.put("notify_url", "http://221.182.45.100:8089/t-sys-order/messageSeparateHandle"); |
| | | map.put("notify_url", "https://haizhentong.com/manage/t-sys-order/messageSeparateHandle"); |
| | | String time = DateUtils.dateTimeNow(); |
| | | |
| | | // SYMBOLS 随机取4位数 |
| | |
| | | |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | //TODO hzt |
| | | map1.put("recv_no", "SR2023081514001"); |
| | | map1.put("recv_no", "SR2024000144253"); |
| | | // 手续费 |
| | | BigDecimal bigDecimal = allMoney.multiply(new BigDecimal("0.038")).setScale(2, RoundingMode.HALF_UP); |
| | | payMoney = payMoney.subtract(bigDecimal); |
| | |
| | | reqMap.put("req_data", map); |
| | | |
| | | |
| | | |
| | | String jsonString = JSON.toJSONString(reqMap); |
| | | // String authorization1 = getAuthorization(jsonString); |
| | | // post.header("Authorization", SCHEMA + " " + authorization); |
| | |
| | | // post.body(jsonString); |
| | | // HttpResponse response = post.execute(); |
| | | // String responseStr = response.body(); |
| | | |
| | | String authorization1 = getAuthorization(jsonString); |
| | | org.apache.http.HttpResponse response1 = post(LakalaConfig.getServerUrl() + "sit/api/v3/sacs/separate", jsonString, authorization1); |
| | | String responseStr = IOUtils.toString(response1.getEntity().getContent(), ENCODING); |
| | | |
| | | System.err.println("分佣!!!!"+responseStr); |
| | | Map<String, ? extends Object> maps = |
| | | new ImmutableMap.Builder<String, String>(). |
| | | put("id", erpProcurement.getId()).put("authorization", authorization1).put("body", jsonString) |
| | | .build(); |
| | | QuartzManager.addJob( |
| | | RevenueSharingJob.class, |
| | | (RevenueSharingJob.name+erpProcurement.getId()).toUpperCase(), |
| | | TimeJobType.REVENUE_SHARING, |
| | | DateUtils.localDateTimeToDate(LocalDateTime.now().plusSeconds(30)), |
| | | maps |
| | | ); |
| | | |
| | | JSONObject jsonObject = JSONObject.parseObject(responseStr); |
| | | if ("成功".equals(jsonObject.getString("msg"))) { |
| | | Object o1 = jsonObject.get("resp_data"); |
| | | JSONObject jsonObject2 = JSONObject.parseObject(o1.toString()); |
| | | String separate_no = jsonObject2.getString("separate_no"); |
| | | erpProcurement.setSeparateNo(separate_no); |
| | | erpProcurementService.updateById(erpProcurement); |
| | | } |
| | | // org.apache.http.HttpResponse response1 = post(LakalaConfig.getServerUrl() + "api/v3/sacs/separate", jsonString, authorization1); |
| | | // String responseStr = IOUtils.toString(response1.getEntity().getContent(), ENCODING); |
| | | // System.err.println("分佣!!!!"+responseStr); |
| | | // JSONObject jsonObject = JSONObject.parseObject(responseStr); |
| | | // if ("成功".equals(jsonObject.getString("msg"))) { |
| | | // Object o1 = jsonObject.get("resp_data"); |
| | | // JSONObject jsonObject2 = JSONObject.parseObject(o1.toString()); |
| | | // String separate_no = jsonObject2.getString("separate_no"); |
| | | // erpProcurement.setSeparateNo(separate_no); |
| | | // erpProcurementService.updateById(erpProcurement); |
| | | // } |
| | | |
| | | // 执行的推送创建云仓订单 |
| | | applicationContext.publishEvent(new TradeOrderEvent(erpProcurement.getId()+"_1")); |
| | | |
| | | // 响应success |
| | | JSONObject responseJsonObject = new JSONObject(); |
| | |
| | | String outTradeNo = time + str; |
| | | String refund_amount = erpProcurement.getPayMoney().multiply(BigDecimal.valueOf(100)).intValue() + ""; |
| | | |
| | | String apiPath = "sit/api/v3/rfd/refund_front/refund"; |
| | | String apiPath = "api/v3/rfd/refund_front/refund"; |
| | | String body1 = "{\n" + |
| | | "\t\"req_data\": {\n" + |
| | | "\t\t\"merchant_no\": \""+erpProcurement.getMerchantNo()+"\",\n" + |
| | |
| | | "\t\t\"out_trade_no\": \"" + outTradeNo + "\",\n" + |
| | | "\t\t\"refund_amount\": \"" + refund_amount + "\",\n" + |
| | | "\t\t\"refund_reason\": \"退款\",\n" + |
| | | "\t\t\"notify_url\": \"" + "http://221.182.45.100:8089/t-sys-order/messageRefundHandle" + "\",\n" + |
| | | "\t\t\"notify_url\": \"" + "https://haizhentong.com/manage/t-sys-order/messageRefundHandle" + "\",\n" + |
| | | "\t\t\"origin_out_trade_no\": \"" + erpProcurement.getPayNumber() + "\",\n" + |
| | | "\t\t\"refund_acc_mode\": \"00\",\n" + |
| | | "\t\t\"refund_amt_sts\": \"00\",\n" + |
| | |
| | | if ( erpProcurement!=null && "SUCCESS".equals(status)) { |
| | | erpProcurement.setStatus(6); |
| | | erpProcurementService.updateById(erpProcurement); |
| | | // 执行的推送取消云仓订单 |
| | | applicationContext.publishEvent(new TradeOrderEvent(erpProcurement.getId()+"_2")); |
| | | // 响应success |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("code", "SUCCESS"); |
| | |
| | | @ApiOperation(value = "退款") |
| | | @PostMapping(value = "/refundOrder") |
| | | @SneakyThrows |
| | | @Log(title = "采购管理-退款", businessType = BusinessType.UPDATE) |
| | | public synchronized R<?> refundOrder(@RequestParam String id, HttpServletRequest request) { |
| | | SysUser user = tokenService.getLoginUser().getUser(); |
| | | try { |
| | |
| | | } |
| | | String outTradeNo = time + str; |
| | | String refund_amount = erpProcurement.getPayMoney().multiply(BigDecimal.valueOf(100)).intValue() + ""; |
| | | String apiPath = "sit/api/v3/rfd/refund_front/refund"; |
| | | String apiPath = "api/v3/rfd/refund_front/refund"; |
| | | String body1 = "{\n" + |
| | | |
| | | "\t\"req_data\": {\n" + |
| | |
| | | "\t\t\"out_trade_no\": \"" + outTradeNo + "\",\n" + |
| | | "\t\t\"refund_amount\": \"" + refund_amount + "\",\n" + |
| | | "\t\t\"refund_reason\": \"退款\",\n" + |
| | | "\t\t\"notify_url\": \"" + "http://221.182.45.100:8089/t-sys-order/messageRefundHandle" + "\",\n" + |
| | | "\t\t\"notify_url\": \"" + "https://haizhentong.com/manage/t-sys-order/messageRefundHandle" + "\",\n" + |
| | | "\t\t\"origin_out_trade_no\": \"" + erpProcurement.getPayNumber() + "\",\n" + |
| | | "\t\t\"refund_acc_mode\": \"00\",\n" + |
| | | "\t\t\"refund_amt_sts\": \"00\",\n" + |
| | |
| | | + IOUtils.toString(response.getEntity().getContent(), ENCODING)); |
| | | } |
| | | String responseStr = IOUtils.toString(response.getEntity().getContent(), ENCODING); |
| | | System.out.println("退款!!"+responseStr); |
| | | JSONObject jsonObject = JSONObject.parseObject(responseStr); |
| | | JSONObject jsonObject2 = jsonObject.getJSONObject("resp_data"); |
| | | String code = jsonObject2.getString("log_no"); |
| | |
| | | // } |
| | | HashMap<String, Object> map1 = new HashMap<>(); |
| | | // TODO hzt |
| | | map1.put("recv_no", "SR2023081514001"); |
| | | map1.put("recv_no", "SR2024000144253"); |
| | | map1.put("amt", erpProcurement.getMoney().multiply(BigDecimal.valueOf(100)).intValue() + ""); |
| | | objects.add(map1); |
| | | map.put("total_amt",erpProcurement.getMoney().multiply(BigDecimal.valueOf(100)).intValue() + ""); |
| | |
| | | String jsonString = JSON.toJSONString(reqMap); |
| | | |
| | | String authorization1 = getAuthorization(jsonString); |
| | | org.apache.http.HttpResponse response1 = post(LakalaConfig.getServerUrl() + "sit/api/v3/sacs/fallback", jsonString, authorization1); |
| | | org.apache.http.HttpResponse response1 = post(LakalaConfig.getServerUrl() + "api/v3/sacs/fallback", jsonString, authorization1); |
| | | String responseStr = IOUtils.toString(response1.getEntity().getContent(), ENCODING); |
| | | |
| | | |