SaleOrderController.java 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package net.chenlin.dp.modules.api.controller;
  2. import com.taobao.api.ApiException;
  3. import net.chenlin.dp.common.openapi4j.exception.OpenAPIException;
  4. import net.chenlin.dp.modules.api.service.SaleOrderService;
  5. import net.chenlin.dp.modules.api.vo.SaleOrderRest;
  6. import net.chenlin.dp.modules.api.vo.YonyouSaleOrder;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. public class SaleOrderController {
  11. private SaleOrderService service=new SaleOrderService();
  12. private DingdingOpenInterface dingdingOpenInterface=new DingdingOpenInterface();
  13. /**
  14. * 获取u8销售订单创建钉钉销售订单审批实列
  15. * @throws OpenAPIException
  16. * @throws ApiException
  17. */
  18. public void dingSaleOrder() throws OpenAPIException, ApiException {
  19. Map<String,String>map=new HashMap<>();
  20. service.getToaccount();
  21. List<YonyouSaleOrder> list = service.yonyouQuerySaleOrder(map);
  22. if (list!=null){
  23. for (YonyouSaleOrder saleOrder:list){
  24. YonyouSaleOrder yonyouSaleOrder = service.yonyouGetSaleOrder(saleOrder.getCode());
  25. if (yonyouSaleOrder!=null){
  26. service.createOrder("PROC-4B526252-017E-4531-91A0-4DEAC6883952",1306561711L,"manager5914",-1L,yonyouSaleOrder);
  27. }
  28. }
  29. }
  30. }
  31. /**
  32. * 销售订单审批后返回u8
  33. * @throws OpenAPIException
  34. */
  35. public void saleOrderShenhe() throws OpenAPIException {
  36. DingdingOpenInterface.getToken();
  37. List<String> orderIdList = dingdingOpenInterface.getOrderIdList("PROC-4B526252-017E-4531-91A0-4DEAC6883952");
  38. if (orderIdList!=null&&!orderIdList.equals("")){
  39. for (String id:orderIdList){
  40. SaleOrderRest saleOrderRest=new SaleOrderRest();
  41. Map<String, Object> orderDetails = dingdingOpenInterface.getOrderDetails(id);
  42. Map<String, Object> map = DingdingOpenInterface.tableToMap(orderDetails);
  43. saleOrderRest.setUser_id("");
  44. Object code = map.get("单据编号");
  45. saleOrderRest.setVoucher_code(code.toString());
  46. Object result = orderDetails.get("result");
  47. if (!result.equals("")&&result!=null){
  48. if (result.equals("agree")){
  49. saleOrderRest.setAgree("1");
  50. }if (result.equals("refuse")){
  51. saleOrderRest.setAgree("0");
  52. }
  53. service.yonyouShenheSaleOrder(saleOrderRest);
  54. }
  55. System.out.println(code+"-"+result);
  56. }
  57. }
  58. }
  59. public static void main(String[] args) throws OpenAPIException, ApiException {
  60. SaleOrderController saleOrderController=new SaleOrderController();
  61. saleOrderController.dingSaleOrder();
  62. }
  63. }