This commit is contained in:
suyl
2021-04-22 16:41:21 +08:00
parent b2c03d6956
commit 910e83ea4b
5 changed files with 40 additions and 28 deletions

View File

@@ -332,14 +332,18 @@ func AcceptJob(ctx *jxcontext.Context, jobID, dropShippingDeliveryID, dropShippi
job.ID = jobID
err = dao.GetEntity(db, job)
if job.UserID == "" || job.Status == model.JobStatusFailed || job.Status == model.JobStatusOverdue || job.FinishedAt.Sub(time.Now()) <= 0 || job.SurplusCount <= 0 || job.LimitCountType <= 0 {
return 0, errCode, fmt.Errorf("未找到该任务或该任务状态不正常,无法接单!")
if job.JobCategoryID == model.JobCategoryIDUnion {
return 0, errCode, fmt.Errorf("活动已结束,请等待下批次活动!")
} else {
return 0, errCode, fmt.Errorf("未找到该任务或该任务状态不正常,无法接单!")
}
}
// num, err = checkJobOrders(db, 0, "<= "+utils.Int2Str(model.JobOrderStatusAccept), userID, utils.ZeroTimeValue, utils.ZeroTimeValue)
// if num >= AcceptMaxCount {
// return 0, errCode, fmt.Errorf("每人最多接取" + utils.Int2Str(AcceptMaxCount) + "个任务,请核实!")
// }
//非快递任务
if jobID != 2 {
if jobID != 2 && job.JobCategoryID != model.JobCategoryIDUnion {
num, err = checkJobOrders(db, jobID, "<= "+utils.Int2Str(model.JobOrderStatusWaitAudit), userID, utils.ZeroTimeValue, utils.ZeroTimeValue)
if num > 0 {
return 0, errCode, fmt.Errorf("您还有此任务未完成,请完成后再接取!")
@@ -1961,26 +1965,24 @@ func GetUnionActList(ctx *jxcontext.Context, vendorID, actType int) (actList []*
return actList, err
}
func ShareUnionLink(ctx *jxcontext.Context, jobID, linkType int) (link string, err error) {
func ShareUnionLink(ctx *jxcontext.Context, jobID, shareType, linkType int) (link string, err error) {
var (
db = dao.GetDB()
job = &model.Job{}
jobOrder = &model.JobOrder{}
job = &model.Job{}
sid string
jobOrderID int64
)
job.ID = jobID
err = dao.GetEntity(db, job)
if err != nil {
return link, err
if shareType == partner.ShareTypeOther {
jobOrderID, _, _ = AcceptJob(ctx, jobID, 0, 0)
} else {
sid = partner.MtUnionJxSID
}
jobOrder.JobID = job.ID
err = dao.GetEntity(db, jobOrder, "JobID")
if err != nil {
return link, err
if jobOrderID != 0 {
sid = utils.Int64ToStr(jobOrderID)
}
if handler := partner.GetHandler(job.VendorID); handler != nil {
link, err = handler.ShareUnionLink(ctx, linkType, job.UnionActID, utils.Int64ToStr(jobOrder.ID))
link, err = handler.ShareUnionLink(ctx, linkType, job.UnionActID, sid)
if job.VendorID == model.VendorIDMTWM && linkType == partner.LinkTypeWeiXinMini {
if resBinary, _, err := jxutils.DownloadFileByURL(link + "?imageView2/1/w/100/h/100/q/75"); err == nil {
if resBinary, _, err := jxutils.DownloadFileByURL(link + "?imageView2/1/w/150/h/150/q/75"); err == nil {
if downloadURL, err := jxutils.UploadExportContent(resBinary, utils.Int64ToStr(time.Now().Unix())+link[strings.LastIndex(link, "/")+1:len(link)]); err == nil {
if err == nil {
link = jxutils.MixWatermarkImg(downloadURL, job.UnionImg, job.UnionQrcodePosition)

View File

@@ -194,7 +194,12 @@ func UnionOrderCallBack(unionOrder *partner.UnionOrderInfo) (err error) {
jobOrder = &model.JobOrder{}
db = dao.GetDB()
)
jobOrder.ID = unionOrder.JobOrderID
if unionOrder.SID == partner.MtUnionJxSID {
globals.SugarLogger.Debugf("result UnionOrderCallBack jxsysorder")
return err
}
jobOrder.ID = utils.Str2Int64(unionOrder.SID)
txDB, _ := dao.Begin(db)
defer func() {
if r := recover(); r != nil {

View File

@@ -14,9 +14,9 @@ func OnCallback(call *mtunionapi.CallBackResult) (err error) {
if call.Status == mtunionapi.MtUnionOrderStatusFinished {
if order, err := api.MtUnionAPI.Rtnotify(call.Orderid, call.Type); order != nil && err == nil {
unionOrder := &partner.UnionOrderInfo{
JobOrderID: utils.Str2Int64(order.Order.Sid),
Profit: jxutils.StandardPrice2Int(utils.Str2Float64(order.Coupon[0].Profit)),
VendorID: model.VendorIDMTWM,
SID: order.Order.Sid,
Profit: jxutils.StandardPrice2Int(utils.Str2Float64(order.Coupon[0].Profit)),
VendorID: model.VendorIDMTWM,
}
cms.UnionOrderCallBack(unionOrder)
}

View File

@@ -11,14 +11,18 @@ var (
)
const (
LinkTypeWeiXinMini = 1 //微信小程序
LinkTypeH5 = 2 //H5
LinkTypeWeiXinMini = 5 //微信小程序二维码
ShareTypeOther = 1 //分享给别人
ShareTypeOwn = 2 //自己领
MtUnionJxSID = "000000001"
)
type UnionOrderInfo struct {
JobOrderID int64 `json:"jobOrderID"`
Profit int64 `json:"profit"` //订单实际返佣金额
VendorID int `json:"vendorID"`
SID string `json:"sid"`
Profit int64 `json:"profit"` //订单实际返佣金额
VendorID int `json:"vendorID"`
}
type ActivityList struct {

View File

@@ -569,14 +569,15 @@ func (c *JobController) GetUnionActList() {
// @Title 分享联盟链接
// @Description 分享联盟链接
// @Param token header string true "认证token"
// @Param jobID formData int true "任务ID"
// @Param linkType formData int true "链接类型1为小程序2为H5"
// @Param jobID formData int false "任务ID"
// @Param shareType formData int true "分享类型1为当前用户分享给别人2为当前用户自己领取"
// @Param linkType formData int true "链接类型1 h5链接 2 deeplink(唤起)链接 3 中间页唤起链接 4 微信小程序唤起路径, 5为小程序二维码"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /ShareUnionLink [post]
func (c *JobController) ShareUnionLink() {
c.callShareUnionLink(func(params *tJobShareUnionLinkParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.ShareUnionLink(params.Ctx, params.JobID, params.LinkType)
retVal, err = cms.ShareUnionLink(params.Ctx, params.JobID, params.ShareType, params.LinkType)
return retVal, "", err
})
}