浏览代码

logistic_check_url

Xingyu Xian 1 周之前
父节点
当前提交
cf60285436
共有 5 个文件被更改,包括 102 次插入2 次删除
  1. 11 1
      .idea/workspace.xml
  2. 59 0
      handler/check_logistic.go
  3. 25 0
      model/http_model/check_logistic.go
  4. 7 0
      route/init.go
  5. 0 1
      service/auto_task.go

+ 11 - 1
.idea/workspace.xml

@@ -5,8 +5,10 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="82c9532a-4868-4653-982c-0f0ec6f4cfe9" name="Changes" comment="logistic_signed_auto_task">
+      <change afterPath="$PROJECT_DIR$/handler/check_logistic.go" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/model/http_model/check_logistic.go" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/db/talent.go" beforeDir="false" afterPath="$PROJECT_DIR$/db/talent.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/route/init.go" beforeDir="false" afterPath="$PROJECT_DIR$/route/init.go" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/service/auto_task.go" beforeDir="false" afterPath="$PROJECT_DIR$/service/auto_task.go" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -14,6 +16,13 @@
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
     <option name="LAST_RESOLUTION" value="IGNORE" />
   </component>
+  <component name="FileTemplateManagerImpl">
+    <option name="RECENT_TEMPLATES">
+      <list>
+        <option value="Go File" />
+      </list>
+    </option>
+  </component>
   <component name="GOROOT" url="file://$USER_HOME$/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.3.windows-amd64" />
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@@ -29,6 +38,7 @@
   </component>
   <component name="PropertiesComponent">{
   &quot;keyToString&quot;: {
+    &quot;DefaultGoTemplateProperty&quot;: &quot;Go File&quot;,
     &quot;Go Build.go build youngee_m_api.executor&quot;: &quot;Run&quot;,
     &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
     &quot;RunOnceActivity.GoLinterPluginOnboarding&quot;: &quot;true&quot;,

+ 59 - 0
handler/check_logistic.go

@@ -0,0 +1,59 @@
+package handler
+
+import (
+	"context"
+	"github.com/caixw/lib.go/conv"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+)
+
+func WrapCheckLogisticHandler(ctx *gin.Context) {
+	handler := newCheckLogisticHandler(ctx)
+	BaseRun(handler)
+}
+
+type CheckLogisticHandler struct {
+	ctx  *gin.Context
+	req  *http_model.CheckLogisticRequest
+	resp *http_model.CommonResponse
+}
+
+func newCheckLogisticHandler(ctx *gin.Context) *CheckLogisticHandler {
+	return &CheckLogisticHandler{
+		ctx:  ctx,
+		req:  http_model.NewCheckLogisticRequest(),
+		resp: http_model.NewCheckLogisticResponse(),
+	}
+}
+
+func (c CheckLogisticHandler) getContext() *gin.Context { return c.ctx }
+func (c CheckLogisticHandler) getResponse() interface{} { return c.resp }
+func (c CheckLogisticHandler) getRequest() interface{} {
+	return c.req
+}
+func (c CheckLogisticHandler) run() {
+	logisticNums := db.GetLogisticsNum()
+	for i := 0; i < len(logisticNums); i++ {
+		logisticNum := logisticNums[i]
+		status := service.GetKDStatus(consts.GetKD(logisticNum[0]), logisticNum[1])
+		if status == "1" {
+			taskId := db.SignLogistic(conv.MustInt64(logisticNum[2], 0))
+			err := db.CreateTaskLog(context.Background(), taskId, "签收时间")
+			if err != nil {
+				logrus.WithContext(context.Background()).Errorf("[logistics service] call CreateTaskLog error,err:%+v", err)
+				c.resp.Status = 40000
+				c.resp.Message = err.Error()
+				return
+			}
+		}
+	}
+	c.resp.Status = 20000
+	c.resp.Message = "ok"
+}
+func (c CheckLogisticHandler) checkParam() error {
+	return nil
+}

+ 25 - 0
model/http_model/check_logistic.go

@@ -0,0 +1,25 @@
+package http_model
+
+type CheckLogisticRequest struct {
+	SubAccountName string `json:"sub_account_name"`
+	Password       string `json:"password"`
+	Job            int    `json:"job_id"`
+	PhoneNumber    string `json:"phone_number"`
+	Code           string `json:"code"`
+	AccountID      int64  `json:"account_id"`
+}
+
+type CheckLogisticRes struct {
+	PhoneNumber    string `json:"phone_number"`
+	SubAccountName string `json:"sub_account_name"`
+	JobID          int    `json:"job_id"`
+}
+
+func NewCheckLogisticRequest() *CheckLogisticRequest {
+	return new(CheckLogisticRequest)
+}
+
+func NewCheckLogisticResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 7 - 0
route/init.go

@@ -445,6 +445,7 @@ func InitRoute(r *gin.Engine) {
 		n.POST("/serveratio", handler.WrapSetServeratioHandler)                  //设置服务费率
 		n.POST("/getserveratio", handler.WrapGetServeratioHandler)               //获取服务费率
 	}
+
 	//通用
 	common := r.Group("/youngee/m/common")
 	{
@@ -452,4 +453,10 @@ func InitRoute(r *gin.Engine) {
 		common.POST("/platform", controller.CommonController{}.CooperationPlatform)     // 获取合作平台icon
 		common.POST("/product/category", controller.CommonController{}.ProductCategory) // 获取商品类目
 	}
+
+	logistic := r.Group("/youngee/logistic")
+	{
+		logistic.GET("/check", handler.WrapCheckLogisticHandler) // 手动查快递
+	}
+	
 }

+ 0 - 1
service/auto_task.go

@@ -289,7 +289,6 @@ func AutoTask() error {
 			}
 			// fmt.Println(err1)
 		}
-
 		println("完成自动刷新AccessToken")
 	}
 	/*