cooperation_service.go 19 KB

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