cooperation_service.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. if param.TaskType == 2 {
  223. // 品牌种草
  224. // 去除当前project_id、supplier_id已在 s_project_info中的数据
  225. var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
  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. enterpriseSupplierCooperates = resEnterpriseSuppliers
  238. } else if param.TaskType == 3 {
  239. // 本地生活
  240. // 去除当前 local_id、supplier_id 已在 s_local_info中的数据
  241. var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
  242. for _, enterpriseSupplier := range enterpriseSupplierCooperates {
  243. var sLocalLifeInfo entity.SLocalLifeInfo
  244. err2 := dao.Db.Model(&entity.SLocalLifeInfo{}).Where("local_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).First(&sLocalLifeInfo).Error
  245. if err2 != nil {
  246. if errors.Is(err2, gorm.ErrRecordNotFound) {
  247. resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
  248. } else {
  249. // 其他错误
  250. }
  251. }
  252. }
  253. enterpriseSupplierCooperates = resEnterpriseSuppliers
  254. }
  255. total = int64(len(enterpriseSupplierCooperates))
  256. } else if param.Status == 2 { // 邀约中
  257. if param.TaskType == 2 {
  258. // 品牌种草
  259. sProjectInfos, total, _ = dao.SProjectDao{}.GetSProjectByStatus(param.TaskId, 1, param.Page, param.PageSize)
  260. } else if param.TaskType == 3 {
  261. // 本地生活
  262. sLocalLifeInfos, total, _ = dao.SLocalLifeDao{}.GetSLocalLifeByStatus(param.TaskId, 1, param.Page, param.PageSize)
  263. }
  264. } else if param.Status == 3 { // 合作中
  265. if param.TaskType == 2 {
  266. // 品牌种草
  267. sProjectInfos, total, _ = dao.SProjectDao{}.GetSProjectByStatus(param.TaskId, 2, param.Page, param.PageSize)
  268. } else if param.TaskType == 3 {
  269. // 本地生活
  270. sLocalLifeInfos, total, _ = dao.SLocalLifeDao{}.GetSLocalLifeByStatus(param.TaskId, 2, param.Page, param.PageSize)
  271. }
  272. }
  273. // 针对邀约中、合作中情形
  274. if enterpriseSupplierCooperates == nil {
  275. if param.TaskType == 2 { // 种草
  276. for _, sProjectInfo := range sProjectInfos {
  277. supplierId := sProjectInfo.SupplierID
  278. enterpriseSupplierCooperate, err1 := dao.EnterpriseSupplierCooperateDao{}.GetDataByEnterpriseAndSupplier(param.EnterpriseId, supplierId)
  279. if err1 != nil {
  280. return result, err1
  281. }
  282. enterpriseSupplierCooperates = append(enterpriseSupplierCooperates, enterpriseSupplierCooperate)
  283. }
  284. } else if param.TaskType == 3 {
  285. // 本地生活
  286. for _, sLocalLifeInfo := range sLocalLifeInfos {
  287. supplierId := sLocalLifeInfo.SupplierID
  288. enterpriseSupplierCooperate, err1 := dao.EnterpriseSupplierCooperateDao{}.GetDataByEnterpriseAndSupplier(param.EnterpriseId, supplierId)
  289. if err1 != nil {
  290. return result, err1
  291. }
  292. enterpriseSupplierCooperates = append(enterpriseSupplierCooperates, enterpriseSupplierCooperate)
  293. }
  294. }
  295. }
  296. for _, enterpriseSupplierCooperate := range enterpriseSupplierCooperates {
  297. // 获取商家操作人姓名
  298. bOperator := enterpriseSupplierCooperate.BOperator
  299. if enterpriseSupplierCooperate.BOperatorType == 1 {
  300. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(bOperator)
  301. if err == nil && enterprise != nil {
  302. enterpriseOperator = enterprise.BusinessName
  303. }
  304. } else if enterpriseSupplierCooperate.BOperatorType == 2 {
  305. subAccountId, err := strconv.ParseInt(bOperator, 10, 64)
  306. if err != nil {
  307. fmt.Println("GetEnterprisePoolList==subAccountId 转换出错:", err)
  308. } else {
  309. subAccount, err := dao.SubAccountDao{}.GetSubAccount(subAccountId)
  310. if err == nil && subAccount != nil {
  311. enterpriseOperator = subAccount.SubAccountName
  312. }
  313. }
  314. }
  315. supplier, err := dao.SupplierDao{}.GetSupplierInfoById(enterpriseSupplierCooperate.SupplierId)
  316. var supplierPreview *vo.ReSupplierPreview
  317. var phoneNumber string
  318. if err == nil && supplier != nil {
  319. supplierPreview = &vo.ReSupplierPreview{
  320. SupplierId: supplier.SupplierID,
  321. HeadUrl: supplier.Avatar,
  322. SupplierName: supplier.SupplierName,
  323. SupplierType: supplier.SupplierType,
  324. CompanyName: supplier.CompanyName,
  325. Name: supplier.Name,
  326. Existence: true,
  327. }
  328. phoneNumber = supplier.PhoneNumber
  329. reSupplierTargetTask := &vo.ReSupplierTargetTask{
  330. SupplierPreview: supplierPreview,
  331. PhoneNumber: phoneNumber,
  332. WechatId: supplier.WechatNumber,
  333. WechatUrl: supplier.WechatQrcode,
  334. CooperateNum: enterpriseSupplierCooperate.CooperateNum,
  335. UploadTalentNum: enterpriseSupplierCooperate.UploadTalentNum,
  336. CooperateTalentNum: enterpriseSupplierCooperate.CooperateTalentNum,
  337. EnterpriseOperator: enterpriseOperator,
  338. Status: param.Status,
  339. }
  340. reSupplierTargetTasks = append(reSupplierTargetTasks, reSupplierTargetTask)
  341. }
  342. }
  343. result = vo.ResultVO{
  344. Page: param.Page,
  345. PageSize: param.PageSize,
  346. Total: total,
  347. Data: reSupplierTargetTasks,
  348. }
  349. return result, nil
  350. }
  351. // 服务商合作-服务商列表角标
  352. func (t CooperationService) GetSupplierInTargetCount(param *vo.SupplierSearchInTargetTaskParam) map[string]int64 {
  353. res := make(map[string]int64)
  354. var invitableNum int64 // 可邀约
  355. var invitingNum int64 // 邀约中
  356. var cooperatingNum int64 // 合作中
  357. if param.TaskType == 2 {
  358. // 品牌种草
  359. var enterpriseSupplierCooperates []*entity.EnterpriseSupplierCooperate
  360. query := dao.Db.Model(&entity.EnterpriseSupplierCooperate{}).Where("enterprise_id = ? AND cooperate_status = 2", param.EnterpriseId)
  361. err := query.Select("supplier_id").Find(&enterpriseSupplierCooperates).Error
  362. var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
  363. if err == nil {
  364. // 去除当前project_id、supplier_id已在 s_project_info中的数据
  365. for _, enterpriseSupplier := range enterpriseSupplierCooperates {
  366. var sProject entity.SProjectInfo
  367. err1 := dao.Db.Debug().Model(&entity.SProjectInfo{}).Where("project_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).First(&sProject).Error
  368. if err1 != nil {
  369. if errors.Is(err1, gorm.ErrRecordNotFound) {
  370. resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
  371. } else {
  372. // 其他错误
  373. }
  374. }
  375. }
  376. }
  377. invitableNum = int64(len(resEnterpriseSuppliers))
  378. dao.Db.Model(&entity.SProjectInfo{}).Where("project_id = ? AND s_project_status = ?", param.TaskId, 1).Count(&invitingNum)
  379. dao.Db.Model(&entity.SProjectInfo{}).Where("project_id = ? AND s_project_status = ?", param.TaskId, 2).Count(&cooperatingNum)
  380. } else if param.TaskType == 3 {
  381. // 本地生活
  382. var enterpriseSupplierCooperates []*entity.EnterpriseSupplierCooperate
  383. query := dao.Db.Model(&entity.EnterpriseSupplierCooperate{}).Where("enterprise_id = ? AND cooperate_status = 2", param.EnterpriseId)
  384. err := query.Select("supplier_id").Find(&enterpriseSupplierCooperates).Error
  385. var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
  386. if err == nil {
  387. // 去除当前local_id、supplier_id已在 s_local_info中的数据
  388. for _, enterpriseSupplier := range enterpriseSupplierCooperates {
  389. var sLocalLifeInfo entity.SLocalLifeInfo
  390. err1 := dao.Db.Model(&entity.SLocalLifeInfo{}).Where("local_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).First(&sLocalLifeInfo).Error
  391. if err1 != nil {
  392. if errors.Is(err1, gorm.ErrRecordNotFound) {
  393. resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
  394. } else {
  395. // 其他错误
  396. }
  397. }
  398. }
  399. }
  400. invitableNum = int64(len(resEnterpriseSuppliers))
  401. dao.Db.Model(&entity.SLocalLifeInfo{}).Where("local_id = ? AND s_local_status = ?", param.TaskId, 1).Count(&invitingNum)
  402. dao.Db.Model(&entity.SProjectInfo{}).Where("local_id = ? AND s_local_status = ?", param.TaskId, 2).Count(&cooperatingNum)
  403. }
  404. res["invitableNum"] = invitableNum
  405. res["invitingNum"] = invitingNum
  406. res["cooperatingNum"] = cooperatingNum
  407. return res
  408. }
  409. // 服务商合作-邀约合作
  410. func (s CooperationService) InviteSupplierInTargetTask(param *vo.SupplierInviteInTargetTaskParam) error {
  411. var err error
  412. if param.TaskType == 2 {
  413. var sProjectInfo entity.SProjectInfo
  414. sProjectInfo.ProjectID = param.TaskId
  415. sProjectInfo.SupplierID = param.SupplierId
  416. sProjectInfo.SProjectStatus = 1
  417. t := time.Now()
  418. sProjectInfo.CreateTime = &t
  419. if param.SubAccountId == 0 {
  420. sProjectInfo.BOperator = param.EnterpriseId
  421. sProjectInfo.BOperatorType = 1
  422. } else {
  423. sProjectInfo.BOperator = strconv.Itoa(int(param.SubAccountId))
  424. sProjectInfo.BOperatorType = 2
  425. }
  426. // 查找该 projectId 对应的信息
  427. project, err1 := dao.ProjectDAO{}.GetProjectById(param.TaskId)
  428. if err1 != nil {
  429. return err1
  430. }
  431. if project != nil {
  432. sProjectInfo.ProductID = project.ProductID
  433. sProjectInfo.ProjectName = project.ProjectName
  434. sProjectInfo.ProjectStatus = project.ProjectStatus
  435. sProjectInfo.ProjectType = project.ProjectType
  436. sProjectInfo.ProjectPlatform = project.ProjectPlatform
  437. sProjectInfo.ProjectForm = project.ProjectForm
  438. sProjectInfo.ContentType = project.ContentType
  439. sProjectInfo.EnterpriseID = param.EnterpriseId
  440. //sProjectInfo.ApplyNum = project.ApplyNum
  441. //sProjectInfo.RecruitNum = project.RecruitNum
  442. }
  443. err = dao.SProjectDao{}.Insert(&sProjectInfo)
  444. } else if param.TaskType == 3 {
  445. // 本地生活
  446. var sLocalLifeInfo entity.SLocalLifeInfo
  447. sLocalLifeInfo.LocalID = param.TaskId
  448. sLocalLifeInfo.SupplierID = param.SupplierId
  449. sLocalLifeInfo.SLocalStatus = 1
  450. t := time.Now()
  451. sLocalLifeInfo.CreateTime = &t
  452. if param.SubAccountId == 0 {
  453. sLocalLifeInfo.BOperator = param.EnterpriseId
  454. sLocalLifeInfo.BOperatorType = 1
  455. } else {
  456. sLocalLifeInfo.BOperator = strconv.Itoa(int(param.SubAccountId))
  457. sLocalLifeInfo.BOperatorType = 2
  458. }
  459. // 查找该 localId 对应的信息
  460. localLife, err1 := dao.LocalLifeDao{}.GetLocalById(param.TaskId)
  461. if err1 != nil {
  462. return err1
  463. }
  464. if localLife != nil {
  465. sLocalLifeInfo.StoreID = localLife.StoreID
  466. sLocalLifeInfo.TeamBuyingID = localLife.TeamBuyingId
  467. sLocalLifeInfo.LocalName = localLife.LocalName
  468. sLocalLifeInfo.TaskStatus = localLife.TaskStatus
  469. sLocalLifeInfo.LocalType = localLife.LocalType
  470. sLocalLifeInfo.LocalPlatform = localLife.LocalPlatform
  471. sLocalLifeInfo.TaskForm = localLife.TaskForm
  472. sLocalLifeInfo.ContentType = localLife.ContentType
  473. sLocalLifeInfo.EnterpriseID = param.EnterpriseId
  474. //sProjectInfo.ApplyNum = project.ApplyNum
  475. //sProjectInfo.RecruitNum = project.RecruitNum
  476. }
  477. err = dao.SLocalLifeDao{}.Insert(&sLocalLifeInfo)
  478. }
  479. return err
  480. }