aa
This commit is contained in:
@@ -1665,129 +1665,255 @@ func UpdateJob(ctx *jxcontext.Context, payload map[string]interface{}) (err erro
|
||||
return err
|
||||
}
|
||||
|
||||
type Store struct {
|
||||
model.ModelIDCULD
|
||||
|
||||
OriginalName string `orm:"-" json:"originalName"`
|
||||
Name string `orm:"size(255)" json:"name"`
|
||||
CityCode int `orm:"default(0);null" json:"cityCode"` // todo ?
|
||||
DistrictCode int `orm:"default(0);null" json:"districtCode"` // todo ?
|
||||
Address string `orm:"size(255)" json:"address"`
|
||||
Tel1 string `orm:"size(32);index" json:"tel1"`
|
||||
Tel2 string `orm:"size(32);index" json:"tel2"`
|
||||
OpenTime1 int16 `json:"openTime1" validate:"max=2359,min=1,ltfield=CloseTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有
|
||||
CloseTime1 int16 `json:"closeTime1" validate:"max=2359,min=1` // 格式同上
|
||||
OpenTime2 int16 `json:"openTime2" validate:"max=2359,min=1,ltfield=CloseTime2"` // 格式同上
|
||||
CloseTime2 int16 `json:"closeTime2" validate:"max=2359,min=1` // 格式同上
|
||||
Lng int `json:"-"` // 乘了10的6次方
|
||||
Lat int `json:"-"` // 乘了10的6次方
|
||||
DeliveryRangeType int8 `json:"deliveryRangeType"` // 参见相关常量定义
|
||||
DeliveryRange string `orm:"type(text)" json:"deliveryRange"` // 如果DeliveryRangeType为DeliveryRangeTypePolygon,则为逗号分隔坐标,分号分隔的坐标点(坐标与Lng和Lat一样,都是整数),比如 121361504,31189308;121420555,31150238。否则为半径,单位为米
|
||||
Status int `json:"status"`
|
||||
AutoEnableAt *time.Time `orm:"type(datetime);null" json:"autoEnableAt"` // 自动营业时间(临时休息用)
|
||||
ChangePriceType int8 `json:"changePriceType"` // 修改价格类型,即是否需要审核
|
||||
SMSNotify int8 `orm:"column(sms_notify);" json:"smsNotify"` // 是否通过短信接收订单消息(每天只推一条)
|
||||
SMSNotifyMark int8 `orm:"column(sms_notify_mark);" json:"smsNotifyMark"` //今天是否已经推送过订单消息
|
||||
AutoReplyType int8 `json:"autoReplyType"` // 订单评价自动回复类型
|
||||
LinkStoreID int `orm:"column(link_store_id);default(0);index" json:"linkStoreID"` // 关联门店ID
|
||||
StoreLevel string `orm:"default(C);size(32)" json:"storeLevel"` // 门店等级(筛选用,京西的)
|
||||
Comment string `orm:"size(255)" json:"comment"` //门店备注
|
||||
|
||||
PrinterDisabled int8 `orm:"default(0)" json:"printerDisabled"` // 是否禁用网络打印机
|
||||
PrinterFontSize int8 `orm:"default(0)" json:"printerFontSize"` // 打印字体-1:小,0:正常,1:大
|
||||
PrinterVendorID int `orm:"column(printer_vendor_id);" json:"printerVendorID"`
|
||||
PrinterSN string `orm:"size(32);column(printer_sn);index" json:"printerSN"`
|
||||
PrinterKey string `orm:"size(64)" json:"printerKey"`
|
||||
PrinterBindInfo string `orm:"size(1024)" json:"-"`
|
||||
|
||||
IDCardFront string `orm:"size(255);column(id_card_front)" json:"idCardFront"`
|
||||
IDCardBack string `orm:"size(255);column(id_card_back)" json:"idCardBack"`
|
||||
IDCardHand string `orm:"size(255);column(id_card_hand)" json:"idCardHand"`
|
||||
Licence string `orm:"size(255)" json:"licence"` // 营业执照图片
|
||||
LicenceCode string `orm:"size(32)" json:"licenceCode"`
|
||||
|
||||
LicenceType int8 `json:"licenceType"` // 营业执照类型,0:个人,1:公司
|
||||
LicenceCorpName string `orm:"size(64)" json:"licenceCorpName"` // 营业执照公司名称
|
||||
LicenceOwnerName string `orm:"size(8)" json:"licenceOwnerName"` // 法人姓名
|
||||
LicenceAddress string `orm:"size(255)" json:"licenceAddress"` // 地址
|
||||
LicenceValid string `orm:"size(32)" json:"licenceValid"` // 有效期开始
|
||||
LicenceExpire string `orm:"size(32)" json:"licenceExpire"` // 有效期结束
|
||||
|
||||
IDName string `orm:"size(8);column(id_name)" json:"idName"` // 身份证姓名
|
||||
IDCode string `orm:"size(32);column(id_code)" json:"idCode"` // 身份证号
|
||||
IDValid string `orm:"column(id_valid);size(32)" json:"idValid"` // 有效期开始
|
||||
IDExpire string `orm:"column(id_expire);size(32)" json:"idExpire"` // 有效期结束
|
||||
|
||||
Licence2Image string `orm:"size(255)" json:"licence2Image"` // 食品经营许可证
|
||||
Licence2Code string `orm:"size(32)" json:"licence2Code"` // 食品经营许可证编号
|
||||
Licence2Valid string `orm:"size(32)" json:"licence2Valid"` // 有效期开始
|
||||
Licence2Expire string `orm:"size(32)" json:"licence2Expire"` // 有效期结束
|
||||
|
||||
// MarketManName string `orm:"size(8)" json:"marketManName"` // 市场负责人姓名
|
||||
MarketManPhone string `orm:"size(16)" json:"marketManPhone"` // 市场负责人电话
|
||||
MarketManRole string `orm:"size(32)" json:"marketManRole"` // 市场负责人组(角色,单人)
|
||||
|
||||
JxBrandFeeFactor int `json:"jxBrandFeeFactor"` // 京西品牌费因子
|
||||
MarketAddFeeFactor int `json:"marketAddFeeFactor"` // 市场附加费因子
|
||||
|
||||
PayeeName string `orm:"size(8)" json:"payeeName"` // 收款人姓名
|
||||
PayeeAccountNo string `orm:"size(255)" json:"payeeAccountNo"` // 收款账号
|
||||
PayeeBankBranchName string `orm:"size(255)" json:"payeeBankBranchName"` // 开户支行
|
||||
PayeeBankCode string `orm:"size(8)" json:"payeeBankCode"` // 开户行代码
|
||||
PayPercentage int `json:"payPercentage"`
|
||||
OldPayPercentage int `json:"oldPayPercentage"`
|
||||
|
||||
StoreFrontPic string `orm:"size(255)" json:"storeFrontPic"` //门面照
|
||||
StoreInPic string `orm:"size(255)" json:"storeInPic"` //门店内照片
|
||||
|
||||
// OperatorName string `orm:"size(8)" json:"operatorName"` // 运营人姓名
|
||||
OperatorPhone string `orm:"size(16)" json:"operatorPhone"` // 京东运营人电话
|
||||
OperatorRole string `orm:"size(32)" json:"operatorRole"` // 京东运营人组(角色)
|
||||
|
||||
OperatorPhone2 string `orm:"size(16)" json:"operatorPhone2"` // 美团运营人电话
|
||||
OperatorRole2 string `orm:"size(32)" json:"operatorRole2"` // 美团运营人组(角色)
|
||||
|
||||
OperatorPhone3 string `orm:"size(16)" json:"operatorPhone3"` // 饿百运营人电话
|
||||
OperatorRole3 string `orm:"size(32)" json:"operatorRole3"` // 饿百运营人组(角色)
|
||||
|
||||
PromoteInfo string `orm:"size(255)" json:"promoteInfo"` //门店公告(所有平台统一的公告)
|
||||
IsBoughtMatter int `json:"isBoughtMatter"` //这周是否申请过物料
|
||||
SoundPercentage int `json:"soundPercentage"` //打印机声音大小比例
|
||||
Banner string `orm:"size(9999)" json:"banner"` //门店商城bannar图
|
||||
BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID
|
||||
VendorStoreID string `orm:"column(vendor_store_id)" json:"vendorStoreID"`
|
||||
}
|
||||
|
||||
func TempJob() (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
ctx = jxcontext.AdminCtx
|
||||
db = dao.GetDB()
|
||||
// ctx = jxcontext.AdminCtx
|
||||
storesJD []*Store
|
||||
// storesMT []*Store
|
||||
)
|
||||
db.Db.Using("c4")
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM
|
||||
SELECT a.*, b.vendor_store_id
|
||||
FROM store a
|
||||
JOIN store_map b ON a.id = b.store_id AND b.vendor_id = 0 AND b.deleted_at = ? AND b.vendor_store_id <> ''
|
||||
WHERE a.deleted_at = ?
|
||||
AND a.id <> 667281
|
||||
AND a.status IN (1,0)
|
||||
`
|
||||
for _, v := range stores {
|
||||
job := &model.Job{
|
||||
UserID: "906380C7390E11EB8831525400C36BDA",
|
||||
JobCategoryID: 3,
|
||||
}
|
||||
sqlParams := []interface{}{utils.DefaultTimeValue, utils.DefaultTimeValue}
|
||||
if err = dao.GetRows(db, &storesJD, sql, sqlParams); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
finishedAt = utils.Str2Time(jobExt.FinishedAtStr)
|
||||
job.FinishedAt = &finishedAt
|
||||
// 需根据任务类型做一些参数判断,比如门店商品链接,地址
|
||||
if job.AvgPrice == 0 {
|
||||
return errCode, fmt.Errorf("请输入单个任务奖励(保证)金额!")
|
||||
}
|
||||
switch job.JobCategoryID {
|
||||
case model.JobCategoryIDwmtg:
|
||||
if job.Address == "" {
|
||||
return errCode, fmt.Errorf("外卖推广任务请输入门店地址!")
|
||||
}
|
||||
case model.JobCategoryIDOther:
|
||||
case model.JobCategoryIDDropShipping:
|
||||
if job.DropShippingAt == 0 {
|
||||
return errCode, fmt.Errorf("一件代发任务请输入承诺x天内发货!")
|
||||
}
|
||||
if job.DropShippingSkuPrice == 0 {
|
||||
return errCode, fmt.Errorf("一件代发任务请输入商品价格!")
|
||||
}
|
||||
job.CashbackType = model.JobCashbackPrice
|
||||
job.LimitCountType = model.JobLimitCountTypeNoLimit
|
||||
job.JobLimitAt = 0
|
||||
job.AuditLimitAt = 0
|
||||
default:
|
||||
return errCode, fmt.Errorf("暂不支持的任务类型! %v", job.JobCategoryID)
|
||||
}
|
||||
// 需根据返现类型做一些参数判断
|
||||
switch job.CashbackType {
|
||||
case model.JobCashbackPercentage:
|
||||
if job.Percentage <= 0 || job.Percentage > 100 {
|
||||
return errCode, fmt.Errorf("返现比例请输入1-100之间的比例!")
|
||||
}
|
||||
case model.JobCashbackPrice:
|
||||
default:
|
||||
return errCode, fmt.Errorf("暂不支持的返现类型! %v", job.CashbackType)
|
||||
}
|
||||
if job.UserID == "" {
|
||||
return errCode, fmt.Errorf("参数有误!")
|
||||
}
|
||||
if ctx.GetUserID() != job.UserID {
|
||||
return errCode, fmt.Errorf("用户信息已过期,请重新登录!")
|
||||
}
|
||||
if job.FinishedAt.Sub(time.Now()) <= 0 {
|
||||
return errCode, fmt.Errorf("任务截止日期必须大于今天!")
|
||||
}
|
||||
if job2, _ := dao.GetJobWithTitle(db, job.Title); job2 != nil {
|
||||
return errCode, fmt.Errorf("任务标题重复,请重新输入!")
|
||||
}
|
||||
if job.JobCityCode != model.JobCountrywideCode {
|
||||
_, _, job.JobCityCode, err = getAddressInfoFromCoord(db, job.JobLng, job.JobLat)
|
||||
}
|
||||
//验证微信绑定
|
||||
if err = auth2.CheckWeixinminiAuthBind(ctx.GetUserID()); err != nil {
|
||||
return "", err
|
||||
}
|
||||
//发布任务要扣除任务总额的保证金,不够扣就要进行充值
|
||||
userBill, err := dao.GetUserBill(db, job.UserID, "")
|
||||
if userBill == nil {
|
||||
return errCode, fmt.Errorf("未查询到该用户的账单!")
|
||||
}
|
||||
job.TotalPrice = job.Count * job.AvgPrice
|
||||
if userBill.AccountBalance < job.TotalPrice {
|
||||
return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足!")
|
||||
}
|
||||
if job.Count <= 0 {
|
||||
return errCode, fmt.Errorf("任务数量不能为0!")
|
||||
}
|
||||
job.SurplusCount = job.Count
|
||||
if job.UserID == "" {
|
||||
return errCode, fmt.Errorf("任务发起人不能为空!")
|
||||
}
|
||||
|
||||
if job.Address != "" && (job.Lng == 0 || job.Lat == 0) {
|
||||
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address, job.JobCityCode)
|
||||
if lng == 0 || lat == 0 {
|
||||
return errCode, fmt.Errorf("请填写完整且正确的门店地址!")
|
||||
}
|
||||
job.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
job.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
}
|
||||
dao.WrapAddIDCULDEntity(job, ctx.GetUserName())
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
if err = dao.CreateEntity(db, job); err != nil {
|
||||
dao.Rollback(db)
|
||||
return
|
||||
}
|
||||
for _, v := range jobExt.JobSteps {
|
||||
dao.WrapAddIDCULDEntity(v, ctx.GetUserName())
|
||||
v.JobID = job.ID
|
||||
err = dao.CreateEntity(db, v)
|
||||
}
|
||||
for _, v := range jobExt.JobImgs {
|
||||
dao.WrapAddIDCULEntity(v, ctx.GetUserName())
|
||||
v.JobID = job.ID
|
||||
err = dao.CreateEntity(db, v)
|
||||
}
|
||||
if err != nil {
|
||||
dao.Rollback(db)
|
||||
return
|
||||
}
|
||||
dao.Commit(db)
|
||||
fmt.Println(utils.Format4Output(storesJD, false))
|
||||
// sql2 := `
|
||||
// SELECT a.*, b.vendor_store_id
|
||||
// FROM store a
|
||||
// JOIN store_map b ON a.id = b.store_id AND b.vendor_id = 1 AND b.deleted_at = ? AND b.vendor_store_id <> ''
|
||||
// WHERE a.deleted_at = ?
|
||||
// AND a.id <> 667281
|
||||
// AND a.status IN (1,0)
|
||||
// `
|
||||
// sqlParams2 := []interface{}{utils.DefaultTimeValue, utils.DefaultTimeValue}
|
||||
// if err = dao.GetRows(db, &storesMT, sql2, sqlParams2); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// db.Db.Using("default")
|
||||
// task := tasksch.NewParallelTask("TempJob", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
// func(task2 *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
// step := batchItemList[0].(int)
|
||||
// switch step {
|
||||
// case 0:
|
||||
// task := tasksch.NewParallelTask("TempJob1", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
// store := batchItemList[0].(*Store)
|
||||
// job := &model.Job{
|
||||
// UserID: "906380C7390E11EB8831525400C36BDA",
|
||||
// JobCategoryID: 3,
|
||||
// Title: "京东(" + store.Name + ")",
|
||||
// Content: "领取任务后,需要尽快去完成,并提交截图。如超时未完成,任务会被取消",
|
||||
// Count: 1000,
|
||||
// AvgPrice: 300,
|
||||
// TotalPrice: 300000,
|
||||
// Status: 0,
|
||||
// Address: store.Address,
|
||||
// StoreURL: store.VendorStoreID,
|
||||
// SurplusCount: 1000,
|
||||
// JobLimitAt: 72,
|
||||
// AuditLimitAt: 168,
|
||||
// LimitCountType: 3,
|
||||
// VendorID: 0,
|
||||
// CashbackType: 1,
|
||||
// JobLat: jxutils.IntCoordinate2Standard(store.Lat),
|
||||
// JobLng: jxutils.IntCoordinate2Standard(store.Lng),
|
||||
// JobCityCode: store.CityCode,
|
||||
// }
|
||||
// finishAt := utils.Str2Time("2021-12-30 00:00:00")
|
||||
// job.FinishedAt = &finishAt
|
||||
// lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address, store.CityCode)
|
||||
// job.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
// job.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
// if err = dao.CreateEntity(db, job); err == nil {
|
||||
// jobsteps, _ := dao.GetJobSteps(db, 171)
|
||||
// for _, v := range jobsteps {
|
||||
// jobStep := &model.JobStep{
|
||||
// JobID: job.ID,
|
||||
// StepCount: v.StepCount,
|
||||
// Content: v.Content,
|
||||
// Img: v.Img,
|
||||
// Type: v.Type,
|
||||
// }
|
||||
// dao.WrapAddIDCULEntity(jobStep, ctx.GetUserName())
|
||||
// err = dao.CreateEntity(db, jobStep)
|
||||
// }
|
||||
// jobImgs, _ := dao.GetJobImgs(db, 171)
|
||||
// for _, v := range jobImgs {
|
||||
// jobImg := &model.JobImg{
|
||||
// JobID: job.ID,
|
||||
// Img: v.Img,
|
||||
// }
|
||||
// dao.WrapAddIDCULEntity(jobImg, ctx.GetUserName())
|
||||
// err = dao.CreateEntity(db, jobImg)
|
||||
// }
|
||||
// }
|
||||
// return retVal, err
|
||||
// }, storesJD)
|
||||
// tasksch.HandleTask(task, task2, true).Run()
|
||||
// task.GetResult(0)
|
||||
// case 1:
|
||||
// task := tasksch.NewParallelTask("TempJob2", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
// store := batchItemList[0].(*Store)
|
||||
// job := &model.Job{
|
||||
// UserID: "906380C7390E11EB8831525400C36BDA",
|
||||
// JobCategoryID: 3,
|
||||
// Title: "美团(" + store.Name + ")",
|
||||
// Content: "领取任务后,需要尽快去完成,并提交截图。如超时未完成,任务会被取消",
|
||||
// Count: 1000,
|
||||
// AvgPrice: 300,
|
||||
// TotalPrice: 300000,
|
||||
// Status: 0,
|
||||
// Address: store.Address,
|
||||
// StoreURL: store.VendorStoreID,
|
||||
// SurplusCount: 1000,
|
||||
// JobLimitAt: 72,
|
||||
// AuditLimitAt: 168,
|
||||
// LimitCountType: 3,
|
||||
// VendorID: 1,
|
||||
// CashbackType: 1,
|
||||
// JobLat: jxutils.IntCoordinate2Standard(store.Lat),
|
||||
// JobLng: jxutils.IntCoordinate2Standard(store.Lng),
|
||||
// JobCityCode: store.CityCode,
|
||||
// }
|
||||
// finishAt := utils.Str2Time("2021-12-31 00:00:00")
|
||||
// job.FinishedAt = &finishAt
|
||||
// lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(job.Address, store.CityCode)
|
||||
// job.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
// job.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
// if err = dao.CreateEntity(db, job); err == nil {
|
||||
// jobsteps, _ := dao.GetJobSteps(db, 171)
|
||||
// for _, v := range jobsteps {
|
||||
// jobStep := &model.JobStep{
|
||||
// JobID: job.ID,
|
||||
// StepCount: v.StepCount,
|
||||
// Content: v.Content,
|
||||
// Img: v.Img,
|
||||
// Type: v.Type,
|
||||
// }
|
||||
// dao.WrapAddIDCULEntity(jobStep, ctx.GetUserName())
|
||||
// err = dao.CreateEntity(db, jobStep)
|
||||
// }
|
||||
// jobImgs, _ := dao.GetJobImgs(db, 171)
|
||||
// for _, v := range jobImgs {
|
||||
// jobImg := &model.JobImg{
|
||||
// JobID: job.ID,
|
||||
// Img: v.Img,
|
||||
// }
|
||||
// dao.WrapAddIDCULEntity(jobImg, ctx.GetUserName())
|
||||
// err = dao.CreateEntity(db, jobImg)
|
||||
// }
|
||||
// }
|
||||
// return retVal, err
|
||||
// }, storesMT)
|
||||
// tasksch.HandleTask(task, task2, true).Run()
|
||||
// task.GetResult(0)
|
||||
// }
|
||||
// return retVal, err
|
||||
// }, []int{0, 1})
|
||||
// tasksch.HandleTask(task, nil, true).Run()
|
||||
// task.GetID()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -592,6 +592,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: "TempJob",
|
||||
Router: `/TempJob`,
|
||||
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: "UpdateJob",
|
||||
|
||||
Reference in New Issue
Block a user