aa
This commit is contained in:
@@ -744,6 +744,11 @@ func AuditJob(ctx *jxcontext.Context, jobOrderID, status int, comment, vendorWay
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
userBill, err := dao.GetUserBill(db, job.UserID, "")
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBill, model.BillTypeDropShippingDeposit, job.AvgPrice, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if job.Status < 0 {
|
||||
@@ -1165,7 +1170,7 @@ func GetDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID string) (queryDyn
|
||||
return api.JdEclpAPI.QueryDynamicTraceInfo(vendorWaybillID)
|
||||
}
|
||||
|
||||
func GetAllDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID, comType string) (result interface{}, err error) {
|
||||
func GetAllDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID, comType string) (result *txcloudapi.GetWaybillDetailInfoResult, err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
getWaybillDetailInfoResult = &txcloudapi.GetWaybillDetailInfoResult{}
|
||||
@@ -1373,3 +1378,82 @@ func ReloadJobSpan(ctx *jxcontext.Context, jobIDs []int, span int) (err error) {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func ConfirmDropShippingJob(ctx *jxcontext.Context, jobOrderID int) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
jobOrder := &model.JobOrder{
|
||||
JobOrderID: int64(jobOrderID),
|
||||
}
|
||||
if err = dao.GetEntity(db, jobOrder, "JobOrderID"); err != nil {
|
||||
return err
|
||||
}
|
||||
job := &model.Job{}
|
||||
job.ID = jobOrder.JobID
|
||||
if err = dao.GetEntity(db, job); err != nil {
|
||||
return err
|
||||
}
|
||||
if ctx.GetUserID() != jobOrder.UserID && ctx.GetUserName() != "jxadmin" {
|
||||
return fmt.Errorf("只有任务接取人才能确认收货!")
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
//确认收货更新时间和收货人
|
||||
jobOrder.DropShippingConfirmTime = time.Now()
|
||||
jobOrder.DropShippingConfirmUser = ctx.GetUserName()
|
||||
jobOrder.Status = model.OrderStatusConfirm
|
||||
if _, err = dao.UpdateEntity(db, jobOrder, "DropShippingConfirmTime", "DropShippingConfirmUser", "Status"); err != nil {
|
||||
dao.Rollback(db)
|
||||
return
|
||||
}
|
||||
userBill, err := dao.GetUserBill(db, job.UserID, "")
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBill, model.BillTypeDropShipping, jobOrder.UserActualPrice, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return
|
||||
}
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
func RefreshDropShippingJob(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
jobOrders []*model.JobOrder
|
||||
)
|
||||
if time.Now().Weekday() != 5 && time.Now().Weekday() != 1 {
|
||||
return
|
||||
}
|
||||
sql := `
|
||||
SELECT a.*
|
||||
FROM job_order a
|
||||
JOIN job b ON a.job_id = b.id AND b.job_category_id = ?
|
||||
WHERE a.waybill_status <= ?
|
||||
AND a.drop_shipping_confirm_user = ''
|
||||
AND a.status = ?
|
||||
AND a.vendor_waybill_id <> ''
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.JobCategoryIDDropShipping,
|
||||
model.OrderStatusFinished,
|
||||
model.OrderStatusFinished,
|
||||
}
|
||||
err = dao.GetRows(db, &jobOrders, sql, sqlParams)
|
||||
task := tasksch.NewParallelTask("RefreshDropShippingJob", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
jobOrder := batchItemList[0].(*model.JobOrder)
|
||||
result, err := GetAllDeliveryDetail(ctx, jobOrder.VendorWaybillID, "")
|
||||
if result.State == utils.Int2Str(txcloudapi.StatusFinished) && time.Now().Sub(utils.Str2Time(result.UpdateTime)) > time.Hour*72 {
|
||||
err = ConfirmDropShippingJob(ctx, int(jobOrder.JobOrderID))
|
||||
}
|
||||
return retVal, err
|
||||
}, jobOrders)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
task.GetID()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ func doDailyWork() {
|
||||
cms.RefreshUserMemberStatus(jxcontext.AdminCtx)
|
||||
//删除聊天记录
|
||||
event.DeleteMessageRecord(jxcontext.AdminCtx)
|
||||
//自动确认收货(刷新状态)
|
||||
cms.RefreshDropShippingJob(jxcontext.AdminCtx)
|
||||
}
|
||||
|
||||
// 按时间序列循环
|
||||
|
||||
@@ -30,7 +30,7 @@ var (
|
||||
BillTypeSpJob: "特殊任务扣除",
|
||||
BillTypeDivide: "群员做任务分成",
|
||||
BillTypeJobDivide: "做任务实得(被扣除分成后)",
|
||||
BillTypeDropShipping: "一件代发订单扣除",
|
||||
BillTypeDropShipping: "一件代发订单收入/扣除",
|
||||
BillTypeDropShippingDeposit: "一件代发保证金",
|
||||
BillTypeMember: "开通会员",
|
||||
BillTypeQuitGroup: "退群",
|
||||
|
||||
@@ -203,6 +203,20 @@ func (c *JobController) AuditJob() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 确认收货(一件代发)
|
||||
// @Description 确认收货(一件代发)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param jobOrderID formData int true "jobOrderID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /ConfirmDropShippingJob [post]
|
||||
func (c *JobController) ConfirmDropShippingJob() {
|
||||
c.callConfirmDropShippingJob(func(params *tJobConfirmDropShippingJobParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.ConfirmDropShippingJob(params.Ctx, params.JobOrderID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 导入美团会员
|
||||
// @Description 导入美团会员
|
||||
// @Param token header string false "认证token"
|
||||
|
||||
@@ -376,6 +376,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"],
|
||||
beego.ControllerComments{
|
||||
Method: "ConfirmDropShippingJob",
|
||||
Router: `/ConfirmDropShippingJob`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:JobController"],
|
||||
beego.ControllerComments{
|
||||
Method: "CreateJobSpan",
|
||||
|
||||
Reference in New Issue
Block a user