aa
This commit is contained in:
@@ -449,6 +449,17 @@ func CancelAcceptJob(ctx *jxcontext.Context, jobID int, jobOrderID int64) (err e
|
||||
}
|
||||
}
|
||||
}
|
||||
//一件代发任务要退钱给用户
|
||||
if job.JobCategoryID == model.JobCategoryIDDropShipping {
|
||||
userBill, err := dao.GetUserBill(db, jobOrder.UserID, "")
|
||||
if userBill == nil {
|
||||
return fmt.Errorf("未查询到该用户的账单!")
|
||||
}
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBill, model.BillTypeJobCancelOverdue, jobOrder.UserActualPrice, jobID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
//3、任务订单状态被取消
|
||||
jobOrder.Status = model.JobOrderStatusCancel
|
||||
if _, err = dao.UpdateEntity(db, jobOrder, "Status"); err != nil {
|
||||
@@ -525,7 +536,7 @@ func UpdateLimitAuditJobOrders(db *dao.DaoDB, timer *time.Timer, jobID int, jobO
|
||||
jobOrder := &model.JobOrder{JobOrderID: jobOrderID}
|
||||
if err := dao.GetEntity(db, jobOrder, "JobOrderID"); err == nil {
|
||||
if jobOrder.Status == model.JobOrderStatusWaitAudit {
|
||||
err := AuditJob(jxcontext.AdminCtx, int(jobOrderID), model.JobOrderStatusAuditPass, "超时系统通过")
|
||||
err := AuditJob(jxcontext.AdminCtx, int(jobOrderID), model.JobOrderStatusAuditPass, "超时系统通过", "")
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("checkLimitAuditJobOrders err: %v jobID: %v, jobOrderID: %v", err, jobID, jobOrderID)
|
||||
} else {
|
||||
@@ -546,10 +557,24 @@ func UpdateDropShippingJobOrders(db *dao.DaoDB, timer *time.Timer, jobID int, jo
|
||||
if err := dao.GetEntity(db, job); err == nil {
|
||||
//如果限时内还没发货
|
||||
if jobOrder.Status < model.JobOrderStatusFinish {
|
||||
|
||||
userBill, err := dao.GetUserBill(db, jobOrder.UserID, "")
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBill, model.BillTypeDropShippingDeposit, job.AvgPrice, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return
|
||||
}
|
||||
dao.Commit(db)
|
||||
}
|
||||
}
|
||||
}
|
||||
jobTimer.Status = model.JobTimerStatusFinish
|
||||
dao.UpdateEntity(db, jobTimer, "Status")
|
||||
}
|
||||
|
||||
func SubmitJob(ctx *jxcontext.Context, jobOrder *model.JobOrder) (err error) {
|
||||
@@ -618,7 +643,7 @@ func SubmitJob(ctx *jxcontext.Context, jobOrder *model.JobOrder) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func AuditJob(ctx *jxcontext.Context, jobOrderID, status int, comment string) (err error) {
|
||||
func AuditJob(ctx *jxcontext.Context, jobOrderID, status int, comment, vendorWaybillID string) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
@@ -631,6 +656,12 @@ func AuditJob(ctx *jxcontext.Context, jobOrderID, status int, comment string) (e
|
||||
if ctx.GetUserID() != job.UserID && ctx.GetUserName() != "jxadmin" {
|
||||
return fmt.Errorf("任务发起人才能审核!")
|
||||
}
|
||||
if job.JobCategoryID == model.JobCategoryIDDropShipping && vendorWaybillID == "" {
|
||||
return fmt.Errorf("一件代发任务发货请输入运单号!")
|
||||
}
|
||||
if job.JobCategoryID == model.JobCategoryIDDropShipping && status != model.JobOrderStatusAuditPass {
|
||||
return fmt.Errorf("一件代发任务发货参数有误!")
|
||||
}
|
||||
//固定返现
|
||||
//1、审核时,若此任务已过期或者已取消,不通过则应将此任务保证金退还给发起人,通过则应将单次任务保证金给接受人
|
||||
//2、若此任务未过期,不通过则此任务剩余数量将+1,通过则应将单次任务保证金给接受人
|
||||
@@ -651,56 +682,66 @@ func AuditJob(ctx *jxcontext.Context, jobOrderID, status int, comment string) (e
|
||||
return
|
||||
}
|
||||
if status == model.JobOrderStatusAuditPass {
|
||||
var price int
|
||||
if job.CashbackType == model.JobCashbackPrice {
|
||||
price = job.AvgPrice
|
||||
} else {
|
||||
price = jobOrder.UserActualPrice * job.Percentage / 100
|
||||
if price > job.AvgPrice {
|
||||
if job.JobCategoryID != model.JobCategoryIDDropShipping {
|
||||
var price int
|
||||
if job.CashbackType == model.JobCashbackPrice {
|
||||
price = job.AvgPrice
|
||||
} else {
|
||||
price = jobOrder.UserActualPrice * job.Percentage / 100
|
||||
if price > job.AvgPrice {
|
||||
price = job.AvgPrice
|
||||
}
|
||||
}
|
||||
}
|
||||
//若完成任务的人在某个群组中,则要向群主分成
|
||||
if messageGroupMembers, err := dao.GetMessageGroupMembers(db, 0, model.GroupTypeMulit, jobOrder.UserID); err == nil {
|
||||
if len(messageGroupMembers) > 1 {
|
||||
return fmt.Errorf("审核异常,该任务提交人加入了多个群组!")
|
||||
} else if len(messageGroupMembers) == 1 {
|
||||
if messageGroupsResult, err := dao.GetMessageGroups(db, "", messageGroupMembers[0].GroupID, model.GroupTypeMulit, false, ""); err == nil {
|
||||
if len(messageGroupsResult) == 1 {
|
||||
//不分成
|
||||
if messageGroupsResult[0].DividePercentage != 0 {
|
||||
if userBillGroupMaster, err := dao.GetUserBill(db, messageGroupsResult[0].UserID, ""); err == nil {
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillGroupMaster, model.BillTypeDivide, price*messageGroupsResult[0].DividePercentage/100, job.ID); err != nil {
|
||||
//若完成任务的人在某个群组中,则要向群主分成
|
||||
if messageGroupMembers, err := dao.GetMessageGroupMembers(db, 0, model.GroupTypeMulit, jobOrder.UserID); err == nil {
|
||||
if len(messageGroupMembers) > 1 {
|
||||
return fmt.Errorf("审核异常,该任务提交人加入了多个群组!")
|
||||
} else if len(messageGroupMembers) == 1 {
|
||||
if messageGroupsResult, err := dao.GetMessageGroups(db, "", messageGroupMembers[0].GroupID, model.GroupTypeMulit, false, ""); err == nil {
|
||||
if len(messageGroupsResult) == 1 {
|
||||
//不分成
|
||||
if messageGroupsResult[0].DividePercentage != 0 {
|
||||
if userBillGroupMaster, err := dao.GetUserBill(db, messageGroupsResult[0].UserID, ""); err == nil {
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillGroupMaster, model.BillTypeDivide, price*messageGroupsResult[0].DividePercentage/100, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
//接收人账户收入
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillJobOrder, model.BillTypeJobDivide, price*(100-messageGroupsResult[0].DividePercentage)/100, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
//接收人账户收入
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillJobOrder, model.BillTypeJob, price, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
//接收人账户收入
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillJobOrder, model.BillTypeJobDivide, price*(100-messageGroupsResult[0].DividePercentage)/100, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
//接收人账户收入
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillJobOrder, model.BillTypeJob, price, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if len(messageGroupMembers) == 0 { //若没有在某个群组,则得到全部
|
||||
//接收人账户收入
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillJobOrder, model.BillTypeJob, price, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
} else if len(messageGroupMembers) == 0 { //若没有在某个群组,则得到全部
|
||||
//接收人账户收入
|
||||
if err = financial.AddIncomeUpdateAccount(db, userBillJobOrder, model.BillTypeJob, price, job.ID); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
jobOrder.Status = model.JobOrderStatusFinish
|
||||
if _, err = dao.UpdateEntity(db, jobOrder, "Status"); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
jobOrder.Status = model.JobOrderStatusFinish
|
||||
if _, err = dao.UpdateEntity(db, jobOrder, "Status"); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
//一件代发处理
|
||||
jobOrder.VendorWaybillID = vendorWaybillID
|
||||
jobOrder.Status = model.JobOrderStatusFinish
|
||||
if _, err = dao.UpdateEntity(db, jobOrder, "Status", "VendorWaybillID"); err != nil {
|
||||
dao.Rollback(db)
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if job.Status < 0 {
|
||||
@@ -1118,8 +1159,14 @@ func GetJdDelivery(ctx *jxcontext.Context, status int, fromTime, toTime string,
|
||||
return dao.GetDeliveryOrders(db, []string{ctx.GetUserID()}, statuss, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
|
||||
}
|
||||
|
||||
func GetJdDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID string) (queryDynamicTraceInfo []*jdeclpapi.QueryDynamicTraceInfoResult, err error) {
|
||||
return api.JdEclpAPI.QueryDynamicTraceInfo(vendorWaybillID)
|
||||
func GetDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID string) (result interface{}, err error) {
|
||||
//如果是京东快递
|
||||
if strings.Contains(vendorWaybillID, "JDVD") {
|
||||
return api.JdEclpAPI.QueryDynamicTraceInfo(vendorWaybillID)
|
||||
} else {
|
||||
//如果是一件代发
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
func CheckJdDeliveryWeight(ctx *jxcontext.Context) (err error) {
|
||||
@@ -1190,6 +1237,8 @@ func ResetJobTimers() {
|
||||
UpdateLimitJobOrders(db, timer, jobTimer.JobID, jobOrders[0].JobOrderID, jobTimer)
|
||||
case model.JobTimerTypeSubmit:
|
||||
UpdateLimitAuditJobOrders(db, timer, jobTimer.JobID, jobOrders[0].JobOrderID, jobTimer)
|
||||
case model.JobTimerTypeDropShipping:
|
||||
UpdateDropShippingJobOrders(db, timer, jobTimer.JobID, jobOrders[0].JobOrderID, jobTimer)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,6 +9,7 @@ const (
|
||||
BillTypeDivide = 15 //群员做任务分成
|
||||
BillTypeJobDivide = 16 //做任务实得(被扣除分成后)
|
||||
BillTypeDropShipping = 17 //一件代发订单扣除
|
||||
BillTypeDropShippingDeposit = 18 //一件代发保证金
|
||||
|
||||
BillTypeMember = 20 //开通会员
|
||||
|
||||
@@ -29,6 +30,8 @@ var (
|
||||
BillTypeSpJob: "特殊任务扣除",
|
||||
BillTypeDivide: "群员做任务分成",
|
||||
BillTypeJobDivide: "做任务实得(被扣除分成后)",
|
||||
BillTypeDropShipping: "一件代发订单扣除",
|
||||
BillTypeDropShippingDeposit: "一件代发保证金",
|
||||
BillTypeMember: "开通会员",
|
||||
BillTypeQuitGroup: "退群",
|
||||
BillTypeJdWaybillOverWeight: "京东物流超重扣款",
|
||||
|
||||
@@ -190,6 +190,7 @@ type JobOrder struct {
|
||||
DropShippingAutoAddress string `json:"dropShippingAutoAddress"`
|
||||
DropShippingCityCode int `json:"dropShippingCityCode"`
|
||||
DropShippingDistrictCode int `json:"dropShippingDistrictCode"`
|
||||
VendorWaybillID string `json:"vendorWaybillID"` //运单号
|
||||
}
|
||||
|
||||
func (v *JobOrder) TableIndex() [][]string {
|
||||
|
||||
@@ -192,12 +192,13 @@ func (c *JobController) SubmitJob() {
|
||||
// @Param jobOrderID formData int true "jobOrderID"
|
||||
// @Param status formData int true "审核标志,15 是通过,20是不通过"
|
||||
// @Param comment formData string false "审核理由"
|
||||
// @Param vendorWaybillID formData string false "运单号(一件代发)"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /AuditJob [post]
|
||||
func (c *JobController) AuditJob() {
|
||||
c.callAuditJob(func(params *tJobAuditJobParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.AuditJob(params.Ctx, params.JobOrderID, params.Status, params.Comment)
|
||||
err = cms.AuditJob(params.Ctx, params.JobOrderID, params.Status, params.Comment, params.VendorWaybillID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -302,16 +303,16 @@ func (c *JobController) GetJdDelivery() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 查询京东快递物流信息
|
||||
// @Description 查询京东快递物流信息
|
||||
// @Title 查询快递物流信息
|
||||
// @Description 查询快递物流信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorWaybillID query string false "运单号"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetJdDeliveryDetail [get]
|
||||
func (c *JobController) GetJdDeliveryDetail() {
|
||||
c.callGetJdDeliveryDetail(func(params *tJobGetJdDeliveryDetailParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.GetJdDeliveryDetail(params.Ctx, params.VendorWaybillID)
|
||||
// @router /GetDeliveryDetail [get]
|
||||
func (c *JobController) GetDeliveryDetail() {
|
||||
c.callGetDeliveryDetail(func(params *tJobGetDeliveryDetailParams) (retVal interface{}, errCode string, err error) {\
|
||||
retVal, err = cms.GetDeliveryDetail(params.Ctx, params.VendorWaybillID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -394,6 +394,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: "GetDeliveryDetail",
|
||||
Router: `/GetDeliveryDetail`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
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: "GetEjyOrders",
|
||||
@@ -412,15 +421,6 @@ 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: "GetJdDeliveryDetail",
|
||||
Router: `/GetJdDeliveryDetail`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
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: "GetJobCategories",
|
||||
|
||||
Reference in New Issue
Block a user