|
@@ -19,27 +19,63 @@ func CompanyReportPermissionTryOut(cont context.Context) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ companyReportPermissionGroupMap := make(map[string][]*models.CompanyReportPermission)
|
|
|
for _, v := range items {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ companyPermissionList, ok := companyReportPermissionGroupMap[fmt.Sprint(v.CompanyId, "-", v.ProductId)]
|
|
|
+ if !ok {
|
|
|
+ companyPermissionList = make([]*models.CompanyReportPermission, 0)
|
|
|
+ }
|
|
|
+ companyPermissionList = append(companyPermissionList, v)
|
|
|
+ companyReportPermissionGroupMap[fmt.Sprint(v.CompanyId, "-", v.ProductId)] = companyPermissionList
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- err = models.CompanyReportPermissionTryOut(v.CompanyReportPermissionId, v.CompanyId, v.ProductId)
|
|
|
+
|
|
|
+ for _, companyReportPermissionList := range companyReportPermissionGroupMap {
|
|
|
+ startDateTime := time.Now()
|
|
|
+ endDateTime := startDateTime.AddDate(0, 2, 0)
|
|
|
+ var companyId, productId int
|
|
|
+ for _, v := range companyReportPermissionList {
|
|
|
+ companyId = v.CompanyId
|
|
|
+ productId = v.ProductId
|
|
|
+
|
|
|
+
|
|
|
+ v.Status = "试用"
|
|
|
+ v.StartDate = startDateTime.Format(utils.FormatDate)
|
|
|
+ v.EndDate = endDateTime.Format(utils.FormatDate)
|
|
|
+ v.ModifyTime = time.Now().Format(utils.FormatDate)
|
|
|
+ err = v.Update([]string{"Status", "StartDate", "EndDate", "ModifyTime"})
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("CompanyReportPermissionTryOut Err:%s" + err.Error())
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ _ = AddCompanyReportPermissionLog(v.CompanyReportPermissionId, v.CompanyId, v.ProductId, utils.AdminId, v.ProductName, utils.RealName, "正式转试用", "try_out", "正式")
|
|
|
+ }
|
|
|
+
|
|
|
+ companyInfo, err := models.GetCompanyProduct(companyId, productId)
|
|
|
if err != nil {
|
|
|
- utils.FileLog.Info("CompanyReportPermissionTryOut Err:%s" + err.Error())
|
|
|
+ utils.FileLog.Info("CompanyReportPermissionTryOut 查找客户信息 Err:%s" + err.Error())
|
|
|
continue
|
|
|
}
|
|
|
-
|
|
|
- _ = AddCompanyReportPermissionLog(v.CompanyReportPermissionId, v.CompanyId, v.ProductId, utils.AdminId, v.ProductName, utils.RealName, "正式转试用", "try_out", v.Status)
|
|
|
+
|
|
|
+ {
|
|
|
+ companyProductTryOutUpdateLog := &models.CompanyProductTryOutUpdateLog{
|
|
|
+ Id: 0,
|
|
|
+ CompanyId: companyId,
|
|
|
+ ProductId: productId,
|
|
|
+ Source: "formal_to_try_out",
|
|
|
+ SellerId: companyInfo.SellerId,
|
|
|
+ SellerName: companyInfo.SellerName,
|
|
|
+ StartDate: startDateTime,
|
|
|
+ EndDate: endDateTime,
|
|
|
+ RealEndDate: startDateTime,
|
|
|
+ IsStop: 0,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ }
|
|
|
+ go models.AddCompanyProductTryOutUpdateLog(companyProductTryOutUpdateLog, companyReportPermissionList)
|
|
|
+ }
|
|
|
}
|
|
|
return
|
|
|
}
|