Sfoglia il codice sorgente

京东订单,详情,退货单,详情,字典初始化,状态更新

1018653686@qq.com 1 anno fa
parent
commit
b679fcf09d

+ 9 - 5
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/controller/jd/JdApiController.java

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.net.URLEncoder;
 
 
 /**
@@ -38,19 +39,22 @@ public class JdApiController {
     @RequestMapping("/callback")
     public void callback(HttpServletResponse response, String code, String state) throws IOException {
         log.info("京东回调code:{},state:{}", code, state);
+        String msg = "";
         if (StrUtil.isBlank(code) || StrUtil.isBlank(state)){
-            response.sendError(HttpStatus.HTTP_BAD_REQUEST, "参数错误");
-            return;
+            msg = "参数错误";
+//            response.sendError(HttpStatus.HTTP_BAD_REQUEST, "参数错误");
+//            return;
         }
         //获取token并且入库
         try{
             jdApiService.getAccessTokenByCode(code);
         }catch (Exception e){
             log.error("京东获取token异常", e);
-            response.sendError(HttpStatus.HTTP_INTERNAL_ERROR, e.getMessage());
-            return;
+            msg = "京东获取token异常";
+//            response.sendError(HttpStatus.HTTP_INTERNAL_ERROR, e.getMessage());
+//            return;
         }
-        response.sendRedirect(DOMAIN + "/callback.html");
+        response.sendRedirect(DOMAIN + "/callback.html?msg="+ URLEncoder.encode(msg));
     }
 
 

+ 13 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/controller/jd/JdBackController.java

@@ -1,8 +1,10 @@
 package com.fjhx.victoriatourist.controller.jd;
 
+import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.victoriatourist.entity.jd.dto.JdBackDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdBackSelectDto;
+import com.fjhx.victoriatourist.entity.jd.dto.JdOrderDto;
 import com.fjhx.victoriatourist.entity.jd.vo.JdBackVo;
 import com.fjhx.victoriatourist.service.jd.JdBackService;
 import com.ruoyi.common.core.domain.BaseSelectDto;
@@ -74,4 +76,15 @@ public class JdBackController {
         jdBackService.excelImport(file, warehouseId);
     }
 
+    /**
+     * 确认采购单
+     */
+    @PostMapping("/confirmBusinessStatus")
+    public void confirmBusinessStatus(@RequestBody JdBackDto jdBackDto) {
+        if(!NumberUtil.isValidNumber(jdBackDto.getId()) || !NumberUtil.isValidNumber(jdBackDto.getBusinessStatus())){
+            throw new RuntimeException("参数错误");
+        }
+        jdBackService.confirmBusinessStatus(jdBackDto);
+    }
+
 }

+ 13 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/controller/jd/JdOrderController.java

@@ -1,5 +1,6 @@
 package com.fjhx.victoriatourist.controller.jd;
 
+import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.victoriatourist.entity.jd.dto.JdOrderDto;
 import com.fjhx.victoriatourist.entity.jd.dto.JdOrderSelectDto;
@@ -112,4 +113,16 @@ public class JdOrderController {
         return jdOrderService.getLogisticsInfo(dto.getId());
     }
 
+    /**
+     * 确认采购单
+     */
+    @PostMapping("/confirmBusinessStatus")
+    public void confirmBusinessStatus(@RequestBody JdOrderDto jdOrderDto) {
+        if(!NumberUtil.isValidNumber(jdOrderDto.getId()) || !NumberUtil.isValidNumber(jdOrderDto.getBusinessStatus())){
+            throw new RuntimeException("参数错误");
+        }
+        jdOrderService.confirmBusinessStatus(jdOrderDto);
+    }
+
+
 }

+ 2 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/entity/jd/po/JdBack.java

@@ -31,6 +31,8 @@ public class JdBack extends BasePo {
      */
     private Integer status;
 
+    private Integer businessStatus;
+
     /**
      * 运单号
      */

+ 4 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/entity/jd/po/JdOrder.java

@@ -88,6 +88,10 @@ public class JdOrder extends BasePo {
     private Integer outStatus;
 
     /**
+     * 业务状态 1=已确认;0=未确认
+     */
+    private Integer businessStatus;
+    /**
      * 出库总数量
      */
     private BigDecimal quantityDelivered;

+ 31 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/entity/jd/vo/TellBackOrderVO.java

@@ -0,0 +1,31 @@
+package com.fjhx.victoriatourist.entity.jd.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+import java.util.List;
+
+@Getter
+@Setter
+public class TellBackOrderVO {
+    /**订单号**/
+    Long orderId;
+    /**预计送货时间**/
+    Date deliveryTime;
+    List<BackInfo> backInfo;
+
+    @Getter
+    @Setter
+    public static class BackInfo {
+        /**
+         * 商品编号(商品编号、配送中心、采购数量个数、不满足发货原因必须保持一致)
+         **/
+        private Long wareId;
+        private Integer confirmNum;
+        private String backExplanation;
+        private Integer backExplanationType;
+        private Integer deliverCenterId;
+    }
+
+}

+ 4 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/JdApiService.java

@@ -1,5 +1,7 @@
 package com.fjhx.victoriatourist.service.jd;
 
+import com.fjhx.victoriatourist.entity.jd.vo.TellBackOrderVO;
+
 public interface JdApiService {
 
     /**
@@ -9,5 +11,7 @@ public interface JdApiService {
 
     String build2LoginUrl();
 
+    void tellBackOrer(TellBackOrderVO tellBackOrderVO);
+
     void test();
 }

+ 2 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/JdBackService.java

@@ -62,4 +62,6 @@ public interface JdBackService extends BaseService<JdBack> {
      * 如果物流状态完成,更新京东退货状态,添加待质检数据
      */
     void updateJdBack(LogisticsInfos logisticsInfo);
+
+    void confirmBusinessStatus(JdBackDto jdBackDto);
 }

+ 2 - 0
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/JdOrderService.java

@@ -61,4 +61,6 @@ public interface JdOrderService extends BaseService<JdOrder> {
      * 根据京东订单id获取物流信息
      */
     List<LogisticsInfosVo> getLogisticsInfo(Long jdOrderInfoId);
+
+    void confirmBusinessStatus(JdOrderDto jdOrderDto);
 }

+ 41 - 1
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/impl/JdApiServiceImpl.java

@@ -27,6 +27,7 @@ import com.fjhx.victoriatourist.entity.jd.po.JdOrder;
 import com.fjhx.victoriatourist.entity.jd.po.JdOrderDetails;
 import com.fjhx.victoriatourist.entity.jd.vo.CommonDictData;
 import com.fjhx.victoriatourist.entity.jd.vo.JdInfoVo;
+import com.fjhx.victoriatourist.entity.jd.vo.TellBackOrderVO;
 import com.fjhx.victoriatourist.service.jd.*;
 import com.fjhx.victoriatourist.service.jd.constants.InitDictConstant;
 import com.fjhx.victoriatourist.service.jd.constants.JdParamConstant;
@@ -125,6 +126,39 @@ public class JdApiServiceImpl implements JdApiService {
         return url;
     }
 
+
+    @Override
+    public void tellBackOrer(TellBackOrderVO tellBackOrderVO) {
+        JdClient client = jdClientFactory.getJdClient();
+        VcConfirmpurchaseorderResponse response;
+        try {
+            VcConfirmpurchaseorderRequest request = buildConfirmpurchaseorderRequest(tellBackOrderVO);
+            response = client.execute(request);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        String code = response.getCode();
+        if(!"200".equals(code)){
+            //失败
+            log.error("回告失败:{},{}",response.getZhDesc(), response.getMsg());
+            throw new RuntimeException("回告失败");
+        }
+    }
+
+    private VcConfirmpurchaseorderRequest buildConfirmpurchaseorderRequest(TellBackOrderVO tellBackOrderVO) {
+        VcConfirmpurchaseorderRequest request = new VcConfirmpurchaseorderRequest();
+        request.setOrderId(tellBackOrderVO.getOrderId());
+        request.setDeliveryTime(tellBackOrderVO.getDeliveryTime());
+        request.setWareId(tellBackOrderVO.getBackInfo().stream().map(o->StrUtil.toString(o.getWareId())).collect(Collectors.joining(",")));
+        request.setConfirmNum(tellBackOrderVO.getBackInfo().stream().map(o->StrUtil.toString(o.getConfirmNum())).collect(Collectors.joining(",")));
+        request.setBackExplanation(tellBackOrderVO.getBackInfo().stream().map(o->StrUtil.toString(o.getBackExplanation())).collect(Collectors.joining(",")));
+        request.setBackExplanationType(tellBackOrderVO.getBackInfo().stream().map(o->StrUtil.toString(o.getBackExplanationType())).collect(Collectors.joining(",")));
+        request.setDeliverCenterId(tellBackOrderVO.getBackInfo().stream().map(o->StrUtil.toString(o.getDeliverCenterId())).collect(Collectors.joining(",")));
+        return request;
+    }
+
+
+
     @Override
     public void test() {
 //        SecurityUtils.setTenantId(tenantId);
@@ -769,7 +803,13 @@ public class JdApiServiceImpl implements JdApiService {
     }
 
     public static void main(String[] args) throws Exception {
-        JdClient client = new DefaultJdClient("http://api.jd.com/routerjson", "a1f79f4670fd43a28fa2de02abd86f03ytfm", JdParamConstant.appKey, JdParamConstant.appSecret);
+//        JdClient client = new DefaultJdClient("http://api.jd.com/routerjson", "a1f79f4670fd43a28fa2de02abd86f03ytfm", JdParamConstant.appKey, JdParamConstant.appSecret);
+        List<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(2);
+        list.add(3);
+        String str = StrUtil.toString(list);
+        System.out.println(str);
     }
 
 }

+ 9 - 1
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/impl/JdBackServiceImpl.java

@@ -22,6 +22,7 @@ import com.fjhx.victoriatourist.entity.jd.dto.JdBackSelectDto;
 import com.fjhx.victoriatourist.entity.jd.po.JdBack;
 import com.fjhx.victoriatourist.entity.jd.po.JdBackDetails;
 import com.fjhx.victoriatourist.entity.jd.po.JdBackQualityWait;
+import com.fjhx.victoriatourist.entity.jd.po.JdOrder;
 import com.fjhx.victoriatourist.entity.jd.vo.JdBackVo;
 import com.fjhx.victoriatourist.entity.logistics.po.LogisticsInfos;
 import com.fjhx.victoriatourist.mapper.jd.JdBackMapper;
@@ -78,7 +79,7 @@ public class JdBackServiceImpl extends ServiceImpl<JdBackMapper, JdBack> impleme
         );
         wrapper.eq("jb", JdBackVo::getType, dto.getType());
         wrapper.eq("jb", JdBackVo::getStatus, dto.getStatus());
-        wrapper.groupBy("jb.id");
+//        wrapper.groupBy("jb.id");
         wrapper.orderByDesc("jb", JdBack::getId);
         Page<JdBackVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         List<JdBackVo> records = page.getRecords();
@@ -397,4 +398,11 @@ public class JdBackServiceImpl extends ServiceImpl<JdBackMapper, JdBack> impleme
         }
     }
 
+
+    @Override
+    public void confirmBusinessStatus(JdBackDto jdBackDto) {
+        lambdaUpdate()
+                .set(JdBack::getBusinessStatus, jdBackDto.getBusinessStatus())
+                .eq(JdBack::getId,jdBackDto.getId()).update();
+    }
 }

+ 22 - 16
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/jd/impl/JdOrderServiceImpl.java

@@ -113,24 +113,24 @@ public class JdOrderServiceImpl extends ServiceImpl<JdOrderMapper, JdOrder> impl
 
         if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
             wrapper.keyword(dto.getKeyword(),
-                    new SqlField("jo", JdOrderVo::getCode),
-                    new SqlField("pi.custom_code"),
-                    new SqlField("pi.name")
+                    new SqlField("jo", JdOrderVo::getCode)
+//                    new SqlField("pi.custom_code"),
+//                    new SqlField("pi.name")
             );
         }
-
-        //添加权限过滤
-        DynamicDataSourceContextHolder.push(SourceConstant.BASE);
-        Set<String> permissionList = sysRoleService.selectRolePermissionByUserId(SecurityUtils.getUserId());
-        DynamicDataSourceContextHolder.poll();
-        if (ObjectUtil.isNotEmpty(permissionList)) {
-            //if当前用户的角色 in [运营专员, 运营助理] 页面仅展示产品.管理部门 == 当前用户所在部门或下级部门的相关数据
-            if (permissionList.contains("E-commerce operation") || permissionList.contains("Operation assistant")) {
-                wrapper.and(q -> q.eq("de.dept_id", SecurityUtils.getDeptId())
-                        .or()
-                        .like("de.ancestors", SecurityUtils.getDeptId()));
-            }
-        }
+//
+//        //添加权限过滤
+//        DynamicDataSourceContextHolder.push(SourceConstant.BASE);
+//        Set<String> permissionList = sysRoleService.selectRolePermissionByUserId(SecurityUtils.getUserId());
+//        DynamicDataSourceContextHolder.poll();
+//        if (ObjectUtil.isNotEmpty(permissionList)) {
+//            //if当前用户的角色 in [运营专员, 运营助理] 页面仅展示产品.管理部门 == 当前用户所在部门或下级部门的相关数据
+//            if (permissionList.contains("E-commerce operation") || permissionList.contains("Operation assistant")) {
+//                wrapper.and(q -> q.eq("de.dept_id", SecurityUtils.getDeptId())
+//                        .or()
+//                        .like("de.ancestors", SecurityUtils.getDeptId()));
+//            }
+//        }
         wrapper.groupBy("jo.id");
 
         Page<JdOrderVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
@@ -648,4 +648,10 @@ public class JdOrderServiceImpl extends ServiceImpl<JdOrderMapper, JdOrder> impl
         return logisticsInfosVos;
     }
 
+    @Override
+    public void confirmBusinessStatus(JdOrderDto jdOrderDto) {
+        lambdaUpdate()
+            .set(JdOrder::getBusinessStatus, jdOrderDto.getBusinessStatus())
+            .eq(JdOrder::getId,jdOrderDto.getId()).update();
+    }
 }

+ 23 - 4
hx-victoriatourist/src/main/resources/mapper/jd/JdBackMapper.xml

@@ -8,17 +8,36 @@
             jb.`status`,
             jb.waybill,
             jb.warehouse_id,
+            jb.business_status,
             jb.batch_flag,
             jb.create_user,
             jb.create_time,
             jb.update_user,
             jb.update_time,
-            li.logistics_company_code,
-            li.`code` logistics_code
+            jb.return_id,
+            jb.provider_code,
+            jb.provider_name,
+            jb.create_date,
+            jb.from_deliver_center_name,
+            jb.to_deliver_center_name,
+            jb.return_state_name,
+            jb.total_num,
+            jb.total_price,
+            jb.stock_name,
+            jb.ware_house_address,
+            jb.ware_house_cell,
+            jb.ware_house_contact,
+            jb.out_store_room_date,
+            jb.ware_variety,
+            jb.balance_state_name,
+            jb.balance_date
+
+        <!--,li.logistics_company_code,
+        li.`code` logistics_code-->
         FROM
             jd_back jb
-                JOIN jd_back_details jbd ON jbd.jd_back_id = jb.id
-                JOIN logistics_infos li ON li.business_id = jb.id
+                <!--JOIN jd_back_details jbd ON jbd.jd_back_id = jb.id
+                JOIN logistics_infos li ON li.business_id = jb.id-->
             ${ew.customSqlSegment}
     </select>
 

+ 42 - 4
hx-victoriatourist/src/main/resources/mapper/jd/JdOrderMapper.xml

@@ -14,15 +14,53 @@
             jo.contact_person,
             jo.contact_number,
             jo.amount,
+            jo.business_status,
             jo.status,
             jo.create_user,
             jo.create_time,
             jo.update_user,
-            jo.update_time
+            jo.update_time,
+            jo.order_id,
+            jo.created_date,
+            jo.provider_code,
+            jo.provider_name,
+            jo.total_price,
+            jo.deliver_center_id,
+            jo.deliver_center_name,
+            jo.purchaser_name,
+            jo.purchaser_erp_code,
+            jo.status_name,
+            jo.is_ept_customized,
+            jo.state,
+            jo.state_name,
+            jo.complete_date,
+            jo.update_date,
+            jo.account_period,
+            jo.receiver_name,
+            jo.warehouse_phone,
+            jo.address,
+            jo.order_type,
+            jo.order_type_name,
+            jo.order_attribute,
+            jo.order_attribute_name,
+            jo.confirm_state,
+            jo.confirm_state_name,
+            jo.custom_order_id,
+            jo.ware_variety,
+            jo.delivery_time,
+            jo.is_can_confirm,
+            jo.is_exist_actual_num_dif,
+            jo.balance_status,
+            jo.storage_time,
+            jo.tc_flag,
+            jo.tc_flag_name,
+            jo.book_time
+
         from jd_order jo
-                 LEFT JOIN jd_order_details jod ON jod.jd_order_id = jo.id
-                 LEFT JOIN bytesailing_item.product_info pi ON jod.product_id = pi.id
-                 LEFT JOIN bytesailing_base.sys_dept de ON CAST(json_unquote(pi.victoriatourist_json -> '$.deptId') AS UNSIGNED) = de.dept_id
+
+            <!--LEFT JOIN jd_order_details jod ON jod.jd_order_id = jo.id
+            LEFT JOIN bytesailing_item.product_info pi ON jod.product_id = pi.id
+            LEFT JOIN bytesailing_base.sys_dept de ON CAST(json_unquote(pi.victoriatourist_json -> '$.deptId') AS UNSIGNED) = de.dept_id-->
             ${ew.customSqlSegment}
     </select>
     <select id="getReceivePage" resultType="com.fjhx.victoriatourist.entity.jd.vo.JdOrderVo">