12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package net.chenlin.dp.modules.api.controller;
- import com.taobao.api.ApiException;
- import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
- import net.chenlin.dp.modules.api.service.SaleOrderService;
- import net.chenlin.dp.modules.api.vo.SaleOrderRest;
- import net.chenlin.dp.modules.api.vo.YonyouSaleOrder;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- public class SaleOrderController {
- private SaleOrderService service=new SaleOrderService();
- private DingdingOpenInterface dingdingOpenInterface=new DingdingOpenInterface();
- /**
- * 获取u8销售订单创建钉钉销售订单审批实列
- * @throws OpenAPIException
- * @throws ApiException
- */
- public void dingSaleOrder() throws OpenAPIException, ApiException {
- Map<String,String>map=new HashMap<>();
- service.getToaccount();
- List<YonyouSaleOrder> list = service.yonyouQuerySaleOrder(map);
- if (list!=null){
- for (YonyouSaleOrder saleOrder:list){
- YonyouSaleOrder yonyouSaleOrder = service.yonyouGetSaleOrder(saleOrder.getCode());
- if (yonyouSaleOrder!=null){
- service.createOrder("PROC-4B526252-017E-4531-91A0-4DEAC6883952",1306561711L,"manager5914",-1L,yonyouSaleOrder);
- }
- }
- }
- }
- /**
- * 销售订单审批后返回u8
- * @throws OpenAPIException
- */
- public void saleOrderShenhe() throws OpenAPIException {
- DingdingOpenInterface.getToken();
- List<String> orderIdList = dingdingOpenInterface.getOrderIdList("PROC-4B526252-017E-4531-91A0-4DEAC6883952");
- if (orderIdList!=null&&!orderIdList.equals("")){
- for (String id:orderIdList){
- SaleOrderRest saleOrderRest=new SaleOrderRest();
- Map<String, Object> orderDetails = dingdingOpenInterface.getOrderDetails(id);
- Map<String, Object> map = DingdingOpenInterface.tableToMap(orderDetails);
- saleOrderRest.setUser_id("");
- Object code = map.get("单据编号");
- saleOrderRest.setVoucher_code(code.toString());
- Object result = orderDetails.get("result");
- if (!result.equals("")&&result!=null){
- if (result.equals("agree")){
- saleOrderRest.setAgree("1");
- }if (result.equals("refuse")){
- saleOrderRest.setAgree("0");
- }
- service.yonyouShenheSaleOrder(saleOrderRest);
- }
- System.out.println(code+"-"+result);
- }
- }
- }
- public static void main(String[] args) throws OpenAPIException, ApiException {
- SaleOrderController saleOrderController=new SaleOrderController();
- saleOrderController.dingSaleOrder();
- }
- }
|