cooperation_service.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. package service
  2. import (
  3. "errors"
  4. "fmt"
  5. "gorm.io/gorm"
  6. "strconv"
  7. "time"
  8. "youngee_b_api/app/dao"
  9. "youngee_b_api/app/entity"
  10. "youngee_b_api/app/vo"
  11. )
  12. type CooperationService struct{}
  13. // 服务商搜索
  14. func (s CooperationService) SearchSupplier(param *vo.SupplierSearchParam) ([]*vo.ReSupplierPreview, error) {
  15. var reSupplierPreviews []*vo.ReSupplierPreview
  16. suppliers, err := dao.SupplierDao{}.GetSuppliersByMsg(param.FieldName)
  17. if err != nil {
  18. return reSupplierPreviews, err
  19. }
  20. for _, supplier := range suppliers {
  21. // 判断该服务商是否已在商家库
  22. exist, _ := dao.EnterpriseSupplierCooperateDao{}.EnterpriseDatabaseCheck(param.EnterpriseId, supplier.SupplierID)
  23. reSupplierPreview := &vo.ReSupplierPreview{
  24. SupplierId: supplier.SupplierID,
  25. HeadUrl: supplier.Avatar,
  26. SupplierName: supplier.SupplierName,
  27. SupplierType: supplier.SupplierType,
  28. CompanyName: supplier.CompanyName,
  29. Name: supplier.Name,
  30. ReviewStatus: supplier.ReviewStatus,
  31. Existence: exist,
  32. }
  33. reSupplierPreviews = append(reSupplierPreviews, reSupplierPreview)
  34. }
  35. return reSupplierPreviews, nil
  36. }
  37. // 服务商入库批量邀请
  38. func (s CooperationService) InviteSupplier(param *vo.SupplierInviteParam) error {
  39. // 要求传入的服务商都是未在该商家库的
  40. var records []*entity.EnterpriseSupplierCooperate
  41. for _, supplierId := range param.SupplierIds {
  42. record := &entity.EnterpriseSupplierCooperate{
  43. EnterpriseId: param.EnterpriseId,
  44. SupplierId: supplierId,
  45. CooperateNum: 1,
  46. CooperateStatus: 1,
  47. CreateTime: time.Now(),
  48. }
  49. if param.SubAccountId == 0 {
  50. record.BOperator = param.EnterpriseId
  51. record.BOperatorType = 1
  52. } else {
  53. record.BOperator = strconv.Itoa(int(param.SubAccountId))
  54. record.BOperatorType = 2
  55. }
  56. records = append(records, record)
  57. }
  58. err := dao.EnterpriseSupplierCooperateDao{}.InsertBatch(records)
  59. return err
  60. }
  61. // 在库服务商列表
  62. func (s CooperationService) GetEnterprisePoolList(param *vo.SupplierSearchInPoolParam) (vo.ResultVO, error) {
  63. if param.Page <= 0 {
  64. param.Page = 1
  65. }
  66. if param.PageSize <= 0 {
  67. param.PageSize = 10
  68. }
  69. var result vo.ResultVO
  70. var reSupplierPoolInfos []*vo.ReSupplierPoolInfo
  71. var enterpriseOperator string
  72. enterpriseSupplierCooperates, total, _ := dao.EnterpriseSupplierCooperateDao{}.GetSupplierByEnterprise(param.EnterpriseId, param.Page, param.PageSize)
  73. for _, enterpriseSupplierCooperate := range enterpriseSupplierCooperates {
  74. // 获取商家操作人姓名
  75. bOperator := enterpriseSupplierCooperate.BOperator
  76. if enterpriseSupplierCooperate.BOperatorType == 1 {
  77. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(bOperator)
  78. if err == nil && enterprise != nil {
  79. enterpriseOperator = enterprise.BusinessName
  80. }
  81. } else if enterpriseSupplierCooperate.BOperatorType == 2 {
  82. subAccountId, err := strconv.ParseInt(bOperator, 10, 64)
  83. if err != nil {
  84. fmt.Println("GetEnterprisePoolList==subAccountId 转换出错:", err)
  85. } else {
  86. subAccount, err := dao.SubAccountDao{}.GetSubAccount(subAccountId)
  87. if err == nil && subAccount != nil {
  88. enterpriseOperator = subAccount.SubAccountName
  89. }
  90. }
  91. }
  92. supplier, err := dao.SupplierDao{}.GetSupplierInfoById(enterpriseSupplierCooperate.SupplierId)
  93. if err != nil {
  94. continue
  95. }
  96. supplierPreview := &vo.ReSupplierPreview{
  97. SupplierId: supplier.SupplierID,
  98. HeadUrl: supplier.Avatar,
  99. SupplierName: supplier.SupplierName,
  100. SupplierType: supplier.SupplierType,
  101. CompanyName: supplier.CompanyName,
  102. Name: supplier.Name,
  103. Existence: true,
  104. }
  105. reSupplierPoolInfo := &vo.ReSupplierPoolInfo{
  106. SupplierPreview: supplierPreview,
  107. PhoneNumber: supplier.PhoneNumber,
  108. WechatId: supplier.WechatNumber,
  109. WechatUrl: supplier.WechatQrcode,
  110. CooperateNum: enterpriseSupplierCooperate.CooperateNum,
  111. UploadTalentNum: enterpriseSupplierCooperate.UploadTalentNum,
  112. CooperateTalentNum: enterpriseSupplierCooperate.CooperateTalentNum,
  113. AgreeTime: enterpriseSupplierCooperate.AgreeTime.Format("2006-01-02 15:04:05"),
  114. EnterpriseOperator: enterpriseOperator,
  115. }
  116. reSupplierPoolInfos = append(reSupplierPoolInfos, reSupplierPoolInfo)
  117. }
  118. result = vo.ResultVO{
  119. Page: param.Page,
  120. PageSize: param.PageSize,
  121. Total: total,
  122. Data: reSupplierPoolInfos,
  123. }
  124. return result, nil
  125. }
  126. // 服务商邀请待确认列表
  127. func (s CooperationService) GetSupplierConfirmingList(param *vo.SupplierConfirmingParam) (vo.ResultVO, error) {
  128. if param.Page <= 0 {
  129. param.Page = 1
  130. }
  131. if param.PageSize <= 0 {
  132. param.PageSize = 10
  133. }
  134. var result vo.ResultVO
  135. var reSupplierConfirmingInfos []*vo.ReSupplierConfirmingInfo
  136. var enterpriseOperator string
  137. enterpriseSupplierCooperates, total, _ := dao.EnterpriseSupplierCooperateDao{}.GetSupplierConfirmingList(param.EnterpriseId, param.Page, param.PageSize)
  138. for _, enterpriseSupplierCooperate := range enterpriseSupplierCooperates {
  139. // 获取商家操作人姓名
  140. bOperator := enterpriseSupplierCooperate.BOperator
  141. if enterpriseSupplierCooperate.BOperatorType == 1 {
  142. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(bOperator)
  143. if err == nil && enterprise != nil {
  144. enterpriseOperator = enterprise.BusinessName
  145. }
  146. } else if enterpriseSupplierCooperate.BOperatorType == 2 {
  147. subAccountId, err := strconv.ParseInt(bOperator, 10, 64)
  148. if err != nil {
  149. fmt.Println("GetSupplierConfirmingList==subAccountId 转换出错:", err)
  150. } else {
  151. subAccount, err := dao.SubAccountDao{}.GetSubAccount(subAccountId)
  152. if err == nil && subAccount != nil {
  153. enterpriseOperator = subAccount.SubAccountName
  154. }
  155. }
  156. }
  157. supplier, err := dao.SupplierDao{}.GetSupplierInfoById(enterpriseSupplierCooperate.SupplierId)
  158. var supplierPreview *vo.ReSupplierPreview
  159. var phoneNumber string
  160. if err == nil {
  161. supplierPreview = &vo.ReSupplierPreview{
  162. SupplierId: supplier.SupplierID,
  163. HeadUrl: supplier.Avatar,
  164. SupplierName: supplier.SupplierName,
  165. SupplierType: supplier.SupplierType,
  166. CompanyName: supplier.CompanyName,
  167. Name: supplier.Name,
  168. }
  169. phoneNumber = supplier.PhoneNumber
  170. reSupplierConfirmingInfo := &vo.ReSupplierConfirmingInfo{
  171. SupplierPreview: supplierPreview,
  172. PhoneNumber: phoneNumber,
  173. WechatId: supplier.WechatNumber,
  174. WechatUrl: supplier.WechatQrcode,
  175. CreateTime: enterpriseSupplierCooperate.CreateTime.Format("2006-01-02 15:04:05"),
  176. Status: enterpriseSupplierCooperate.CooperateStatus,
  177. EnterpriseOperator: enterpriseOperator,
  178. }
  179. reSupplierConfirmingInfos = append(reSupplierConfirmingInfos, reSupplierConfirmingInfo)
  180. }
  181. }
  182. result = vo.ResultVO{
  183. Page: param.Page,
  184. PageSize: param.PageSize,
  185. Total: total,
  186. Data: reSupplierConfirmingInfos,
  187. }
  188. return result, nil
  189. }
  190. // 服务商管理-角标
  191. func (t CooperationService) GetSupplierCount(param *vo.SupplierConfirmingParam) map[string]int64 {
  192. res := make(map[string]int64)
  193. var inPoolNum int64 // 在库服务商
  194. var confirmingNum int64 // 邀请待确认
  195. dao.Db.Model(&entity.EnterpriseSupplierCooperate{}).Where("enterprise_id = ? AND cooperate_status = 2", param.EnterpriseId).Count(&inPoolNum)
  196. dao.Db.Model(&entity.EnterpriseSupplierCooperate{}).Where("enterprise_id = ? AND cooperate_status = 1", param.EnterpriseId).Count(&confirmingNum)
  197. res["inPoolNum"] = inPoolNum
  198. res["confirmingNum"] = confirmingNum
  199. return res
  200. }
  201. // 服务商合作-服务商列表
  202. func (s CooperationService) GetSupplierInTargetTaskList(param *vo.SupplierSearchInTargetTaskParam) (vo.ResultVO, error) {
  203. if param.Page <= 0 {
  204. param.Page = 1
  205. }
  206. if param.PageSize <= 0 {
  207. param.PageSize = 10
  208. }
  209. var reSupplierTargetTasks []*vo.ReSupplierTargetTask
  210. var total int64
  211. result := vo.ResultVO{
  212. Page: param.Page,
  213. PageSize: param.PageSize,
  214. Total: total,
  215. Data: reSupplierTargetTasks,
  216. }
  217. var enterpriseSupplierCooperates []*entity.EnterpriseSupplierCooperate
  218. var sProjectInfos []*entity.SProjectInfo
  219. var sLocalLifeInfos []*entity.SLocalLifeInfo
  220. var enterpriseOperator string
  221. if param.Status == 1 { // 可邀约
  222. enterpriseSupplierCooperates, total, _ = dao.EnterpriseSupplierCooperateDao{}.GetSupplierByEnterprise(param.EnterpriseId, param.Page, param.PageSize)
  223. var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
  224. if param.TaskType == 2 {
  225. // 品牌种草
  226. // 去除当前project_id、supplier_id已在 s_project_info中的数据
  227. for _, enterpriseSupplier := range enterpriseSupplierCooperates {
  228. var sProject entity.SProjectInfo
  229. err1 := dao.Db.Model(&entity.SProjectInfo{}).Where("project_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).First(&sProject).Error
  230. if err1 != nil {
  231. if errors.Is(err1, gorm.ErrRecordNotFound) {
  232. resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
  233. } else {
  234. // 其他错误
  235. }
  236. }
  237. }
  238. } else if param.TaskType == 3 {
  239. // 本地生活
  240. // 去除当前 local_id、supplier_id 已在 s_local_info中的数据
  241. for _, enterpriseSupplier := range enterpriseSupplierCooperates {
  242. var sLocalLifeInfo entity.SLocalLifeInfo
  243. err2 := dao.Db.Model(&entity.SLocalLifeInfo{}).Where("local_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).First(&sLocalLifeInfo).Error
  244. if err2 != nil {
  245. if errors.Is(err2, gorm.ErrRecordNotFound) {
  246. resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
  247. } else {
  248. // 其他错误
  249. }
  250. }
  251. }
  252. }
  253. enterpriseSupplierCooperates = resEnterpriseSuppliers
  254. total = int64(len(enterpriseSupplierCooperates))
  255. } else if param.Status == 2 { // 邀约中
  256. if param.TaskType == 2 {
  257. // 品牌种草
  258. sProjectInfos, total, _ = dao.SProjectDao{}.GetSProjectByStatus(param.TaskId, 1, param.Page, param.PageSize)
  259. } else if param.TaskType == 3 {
  260. // 本地生活
  261. sLocalLifeInfos, total, _ = dao.SLocalLifeDao{}.GetSLocalLifeByStatus(param.TaskId, 1, param.Page, param.PageSize)
  262. }
  263. } else if param.Status == 3 { // 合作中
  264. if param.TaskType == 2 {
  265. // 品牌种草
  266. sProjectInfos, total, _ = dao.SProjectDao{}.GetSProjectByStatus(param.TaskId, 2, param.Page, param.PageSize)
  267. } else if param.TaskType == 3 {
  268. // 本地生活
  269. sLocalLifeInfos, total, _ = dao.SLocalLifeDao{}.GetSLocalLifeByStatus(param.TaskId, 2, param.Page, param.PageSize)
  270. }
  271. }
  272. // 针对邀约中、合作中情形
  273. if param.Status == 2 || param.Status == 3 {
  274. if param.TaskType == 2 { // 种草
  275. for _, sProjectInfo := range sProjectInfos {
  276. supplierId := sProjectInfo.SupplierID
  277. enterpriseSupplierCooperate, err1 := dao.EnterpriseSupplierCooperateDao{}.GetDataByEnterpriseAndSupplier(param.EnterpriseId, supplierId)
  278. if err1 != nil {
  279. return result, err1
  280. }
  281. enterpriseSupplierCooperates = append(enterpriseSupplierCooperates, enterpriseSupplierCooperate)
  282. }
  283. } else if param.TaskType == 3 {
  284. // 本地生活
  285. for _, sLocalLifeInfo := range sLocalLifeInfos {
  286. supplierId := sLocalLifeInfo.SupplierID
  287. enterpriseSupplierCooperate, err1 := dao.EnterpriseSupplierCooperateDao{}.GetDataByEnterpriseAndSupplier(param.EnterpriseId, supplierId)
  288. if err1 != nil {
  289. return result, err1
  290. }
  291. enterpriseSupplierCooperates = append(enterpriseSupplierCooperates, enterpriseSupplierCooperate)
  292. }
  293. }
  294. }
  295. for _, enterpriseSupplierCooperate := range enterpriseSupplierCooperates {
  296. // 获取商家操作人姓名
  297. bOperator := enterpriseSupplierCooperate.BOperator
  298. if enterpriseSupplierCooperate.BOperatorType == 1 {
  299. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(bOperator)
  300. if err == nil && enterprise != nil {
  301. enterpriseOperator = enterprise.BusinessName
  302. }
  303. } else if enterpriseSupplierCooperate.BOperatorType == 2 {
  304. subAccountId, err := strconv.ParseInt(bOperator, 10, 64)
  305. if err != nil {
  306. fmt.Println("GetEnterprisePoolList==subAccountId 转换出错:", err)
  307. } else {
  308. subAccount, err := dao.SubAccountDao{}.GetSubAccount(subAccountId)
  309. if err == nil && subAccount != nil {
  310. enterpriseOperator = subAccount.SubAccountName
  311. }
  312. }
  313. }
  314. supplier, err := dao.SupplierDao{}.GetSupplierInfoById(enterpriseSupplierCooperate.SupplierId)
  315. var supplierPreview *vo.ReSupplierPreview
  316. var phoneNumber string
  317. if err == nil && supplier != nil {
  318. supplierPreview = &vo.ReSupplierPreview{
  319. SupplierId: supplier.SupplierID,
  320. HeadUrl: supplier.Avatar,
  321. SupplierName: supplier.SupplierName,
  322. SupplierType: supplier.SupplierType,
  323. CompanyName: supplier.CompanyName,
  324. Name: supplier.Name,
  325. Existence: true,
  326. }
  327. phoneNumber = supplier.PhoneNumber
  328. reSupplierTargetTask := &vo.ReSupplierTargetTask{
  329. SupplierPreview: supplierPreview,
  330. PhoneNumber: phoneNumber,
  331. WechatId: supplier.WechatNumber,
  332. WechatUrl: supplier.WechatQrcode,
  333. CooperateNum: enterpriseSupplierCooperate.CooperateNum,
  334. UploadTalentNum: enterpriseSupplierCooperate.UploadTalentNum,
  335. CooperateTalentNum: enterpriseSupplierCooperate.CooperateTalentNum,
  336. EnterpriseOperator: enterpriseOperator,
  337. Status: param.Status,
  338. }
  339. reSupplierTargetTasks = append(reSupplierTargetTasks, reSupplierTargetTask)
  340. }
  341. }
  342. result = vo.ResultVO{
  343. Page: param.Page,
  344. PageSize: param.PageSize,
  345. Total: total,
  346. Data: reSupplierTargetTasks,
  347. }
  348. return result, nil
  349. }
  350. // 服务商合作-服务商列表角标
  351. func (t CooperationService) GetSupplierInTargetCount(param *vo.SupplierSearchInTargetTaskParam) map[string]int64 {
  352. res := make(map[string]int64)
  353. var invitableNum int64 // 可邀约
  354. var invitingNum int64 // 邀约中
  355. var cooperatingNum int64 // 合作中
  356. if param.TaskType == 2 {
  357. // 品牌种草
  358. var enterpriseSupplierCooperates []*entity.EnterpriseSupplierCooperate
  359. query := dao.Db.Model(&entity.EnterpriseSupplierCooperate{}).Where("enterprise_id = ? AND cooperate_status = 2", param.EnterpriseId)
  360. err := query.Select("supplier_id").Find(&enterpriseSupplierCooperates).Error
  361. var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
  362. if err == nil {
  363. // 去除当前project_id、supplier_id已在 s_project_info中的数据
  364. for _, enterpriseSupplier := range enterpriseSupplierCooperates {
  365. var sProject entity.SProjectInfo
  366. err1 := dao.Db.Debug().Model(&entity.SProjectInfo{}).Where("project_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).First(&sProject).Error
  367. if err1 != nil {
  368. if errors.Is(err1, gorm.ErrRecordNotFound) {
  369. resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
  370. } else {
  371. // 其他错误
  372. }
  373. }
  374. }
  375. }
  376. invitableNum = int64(len(resEnterpriseSuppliers))
  377. dao.Db.Model(&entity.SProjectInfo{}).Where("project_id = ? AND s_project_status = ?", param.TaskId, 1).Count(&invitingNum)
  378. dao.Db.Model(&entity.SProjectInfo{}).Where("project_id = ? AND s_project_status = ?", param.TaskId, 2).Count(&cooperatingNum)
  379. } else if param.TaskType == 3 {
  380. // 本地生活
  381. var enterpriseSupplierCooperates []*entity.EnterpriseSupplierCooperate
  382. query := dao.Db.Model(&entity.EnterpriseSupplierCooperate{}).Where("enterprise_id = ? AND cooperate_status = 2", param.EnterpriseId)
  383. err := query.Select("supplier_id").Find(&enterpriseSupplierCooperates).Error
  384. var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
  385. if err == nil {
  386. // 去除当前local_id、supplier_id已在 s_local_info中的数据
  387. for _, enterpriseSupplier := range enterpriseSupplierCooperates {
  388. var sLocalLifeInfo entity.SLocalLifeInfo
  389. err1 := dao.Db.Model(&entity.SLocalLifeInfo{}).Where("local_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).First(&sLocalLifeInfo).Error
  390. if err1 != nil {
  391. if errors.Is(err1, gorm.ErrRecordNotFound) {
  392. resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
  393. } else {
  394. // 其他错误
  395. }
  396. }
  397. }
  398. }
  399. invitableNum = int64(len(resEnterpriseSuppliers))
  400. dao.Db.Model(&entity.SLocalLifeInfo{}).Where("local_id = ? AND s_local_status = ?", param.TaskId, 1).Count(&invitingNum)
  401. dao.Db.Model(&entity.SProjectInfo{}).Where("local_id = ? AND s_local_status = ?", param.TaskId, 2).Count(&cooperatingNum)
  402. }
  403. res["invitableNum"] = invitableNum
  404. res["invitingNum"] = invitingNum
  405. res["cooperatingNum"] = cooperatingNum
  406. return res
  407. }
  408. // 服务商合作-邀约合作
  409. func (s CooperationService) InviteSupplierInTargetTask(param *vo.SupplierInviteInTargetTaskParam) error {
  410. var err error
  411. if param.TaskType == 2 {
  412. var sProjectInfo entity.SProjectInfo
  413. sProjectInfo.ProjectID = param.TaskId
  414. sProjectInfo.SupplierID = param.SupplierId
  415. sProjectInfo.SProjectStatus = 1
  416. t := time.Now()
  417. sProjectInfo.CreateTime = &t
  418. if param.SubAccountId == 0 {
  419. sProjectInfo.BOperator = param.EnterpriseId
  420. sProjectInfo.BOperatorType = 1
  421. } else {
  422. sProjectInfo.BOperator = strconv.Itoa(int(param.SubAccountId))
  423. sProjectInfo.BOperatorType = 2
  424. }
  425. // 查找该 projectId 对应的信息
  426. project, err1 := dao.ProjectDAO{}.GetProjectById(param.TaskId)
  427. if err1 != nil {
  428. return err1
  429. }
  430. if project != nil {
  431. sProjectInfo.ProductID = project.ProductID
  432. sProjectInfo.ProjectName = project.ProjectName
  433. sProjectInfo.ProjectStatus = project.ProjectStatus
  434. sProjectInfo.ProjectType = project.ProjectType
  435. sProjectInfo.ProjectPlatform = project.ProjectPlatform
  436. sProjectInfo.ProjectForm = project.ProjectForm
  437. sProjectInfo.ContentType = project.ContentType
  438. sProjectInfo.EnterpriseID = param.EnterpriseId
  439. //sProjectInfo.ApplyNum = project.ApplyNum
  440. //sProjectInfo.RecruitNum = project.RecruitNum
  441. }
  442. err = dao.SProjectDao{}.Insert(&sProjectInfo)
  443. } else if param.TaskType == 3 {
  444. // 本地生活
  445. var sLocalLifeInfo entity.SLocalLifeInfo
  446. sLocalLifeInfo.LocalID = param.TaskId
  447. sLocalLifeInfo.SupplierID = param.SupplierId
  448. sLocalLifeInfo.SLocalStatus = 1
  449. t := time.Now()
  450. sLocalLifeInfo.CreateTime = &t
  451. if param.SubAccountId == 0 {
  452. sLocalLifeInfo.BOperator = param.EnterpriseId
  453. sLocalLifeInfo.BOperatorType = 1
  454. } else {
  455. sLocalLifeInfo.BOperator = strconv.Itoa(int(param.SubAccountId))
  456. sLocalLifeInfo.BOperatorType = 2
  457. }
  458. // 查找该 localId 对应的信息
  459. localLife, err1 := dao.LocalLifeDao{}.GetLocalById(param.TaskId)
  460. if err1 != nil {
  461. return err1
  462. }
  463. if localLife != nil {
  464. sLocalLifeInfo.StoreID = localLife.StoreID
  465. sLocalLifeInfo.TeamBuyingID = localLife.TeamBuyingId
  466. sLocalLifeInfo.LocalName = localLife.LocalName
  467. sLocalLifeInfo.TaskStatus = localLife.TaskStatus
  468. sLocalLifeInfo.LocalType = localLife.LocalType
  469. sLocalLifeInfo.LocalPlatform = localLife.LocalPlatform
  470. sLocalLifeInfo.TaskForm = localLife.TaskForm
  471. sLocalLifeInfo.ContentType = localLife.ContentType
  472. sLocalLifeInfo.EnterpriseID = param.EnterpriseId
  473. //sProjectInfo.ApplyNum = project.ApplyNum
  474. //sProjectInfo.RecruitNum = project.RecruitNum
  475. }
  476. err = dao.SLocalLifeDao{}.Insert(&sLocalLifeInfo)
  477. }
  478. return err
  479. }