<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<task id="__yxIdPQn7Q1OwTMxQ0MG">
  <name>确认成绩人员订单收货</name>
  <parentId>__LgZds5MVHW3o08T7UcX</parentId>
  <applicationid>__LgZds5MVHW3o08T7UcX</applicationid>
  <description>确认成绩人员订单收货</description>
  <type>1</type>
  <runningTime>2023-09-13T09:38:45.000+08:00</runningTime>
  <interval>5</interval>
  <period>34</period>
  <runtimes>0</runtimes>
  <terminateScript><![CDATA[]]></terminateScript>
  <taskScript><![CDATA[(function(){
  var address = "v5qy.te";
  var url = ""
  var domainidlist = new Packages.java.util.ArrayList();
  var uporderlist = "(";
  var sqldomain = "select domainid from tlk_learn_order_person where item_order_no is not null and item_order_no != '' and item_order_no_refund_status = '3' group by domainid limit 20";
  var datasdomain = queryByDSName("tms",sqldomain);
  if(datasdomain!="[]"){
    for(var iterator = datasdomain.iterator();iterator.hasNext();){
      var map1 = iterator.next();//取值
      var domainidset = map1.get("domainid");
      println("domainidset---------"+domainidset);
      domainidlist.add(domainidset);
      println("domainidlist------------"+domainidlist)
    }
  }
  if(domainidlist == null || domainidlist.size() <= 0){
  }else{
    println("进来了吗-----------"+domainidlist.size())
    for(var u=0;u<domainidlist.size();u++){
      var domainid = domainidlist.get(u);
      var orgdomainid = 'org_'+domainid;
      var accessToken = Packages.cn.myapps.common.util.Security.getToken(orgdomainid);
      println("orgdomainid-------------"+orgdomainid);
      if (address.indexOf("v5qy.de") != "-1") {
        url = "https://shop.ws.baibaodun.com.cn/api/front/order/take/delivery/orders";
      }else if(address.indexOf("v5qy.te") != "-1"){
        url = "https://shop.ws.baibaodun.com.cn/api/front/order/take/delivery/orders";
      }else if(address.indexOf("v5prod.pre") != "-1"){
        url = "​https://shop.mall.pre.baibaodun.cn/api/front/order/take/delivery/orders"
      }else{
        url = "​https://shop.mall.baibaodun.cn/api/front/order/take/delivery/orders"
      }
      var sql = "select item_order_no,domainid from tlk_learn_order_person where item_order_no is not null and item_order_no != '' and item_order_no_refund_status = '3' and domainid = '"+domainid+"' order by created limit 20";
      var order_no_list = new Packages.java.util.ArrayList();
      var datas = queryByDSName("tms",sql);
      var header = new Packages.java.util.HashMap();
      header.put("Content-Type","application/json")
      println("bcxToken------------------"+accessToken)
      header.put("bcxToken",accessToken);
      if(datas!="[]"){
        for(var iterator = datas.iterator();iterator.hasNext();){
          var map1 = iterator.next();//取值
          var order_no = map1.get("item_order_no");
          order_no_list.add(order_no)
        }
      }
      var body = new Packages.java.util.HashMap();
      body.put("orderNos",order_no_list);
      if(order_no_list == null || order_no_list.size() <= 0){

      }else if(isNotNull(url) && isNotNull(header) && isNotNull(body)){ 
        println("order_no--------------"+order_no_list);
        println("url-----------"+url);
        println("header-----------"+header);
        println("body1------------"+body);
        body = Packages.com.alibaba.fastjson.JSON.toJSONString(body);
        println("body2------------"+body);
        var response = Packages.cn.hutool.http.HttpUtil.createPost(url).addHeaders(header).body(body).execute().body();
        var process = getDocumentProcess();
        var formProcess = getFormProcess();
        var subform = formProcess.doView("__1TzvpG91G635jf42KRD");
        var doc = process.doNew(subform, getWebUser(), createParamsTable());
        doc.addStringItem("url", url);
        doc.addStringItem("request",body);
        doc.addStringItem("response",response);
        process.doCreate(doc);
        println("response------------"+response)
        var response = eval('('+response+')');
        println("code-----------"+response.code)
        println("message--------------"+response.message);
        println("data---------"+response.data);
        var data = response.data
        for(var i=0;i<data.length;i++){
          var orderNo = data[i].orderNo;
          var succeess = data[i].success;
          var message = data[i].message;
          println("orderNo------------"+orderNo)
          println("success------------"+succeess)
          println("message------------"+message)
          if("true".equals(succeess)){
            println("进来！");
            uporderlist += "'";
            uporderlist += orderNo
            uporderlist += "'"
            uporderlist += ",";
          }
        }
      }
    }
  }
  println("uporderlist------------"+uporderlist)
  if(!"(".equals(uporderlist)){
    uporderlist = uporderlist.substr(0,uporderlist.length-1);
    println("uporderlist------2------"+uporderlist)
    uporderlist += ")";
    println("uporderlist------3------"+uporderlist)
    var uporderlistsql = "update tlk_learn_order_person set item_order_no_refund_status = '4' where item_order_no in "+uporderlist+";"
    println("uporderlistsql---------"+uporderlistsql)
    updateByDSName("tms",uporderlistsql);
  }



})()]]></taskScript>
  <modifyTime>2023-09-13T09:38:45.000+08:00</modifyTime>
  <creator>Admin</creator>
  <creatorid>Ai6hllhNjS2ull9TKGb</creatorid>
  <totalRuntimes>0</totalRuntimes>
  <state>0</state>
  <startupType>1</startupType>
  <dayOfMonth>1</dayOfMonth>
  <repeatTimes>0</repeatTimes>
  <frequency>0</frequency>
  <executedCount>0</executedCount>
  <rDate></rDate>
  <rTime></rTime>
</task>