$this->luckydraw_campaignId 是我们的主的campaignId
1.插入新draw的记录到 ‘db_central.overall_campaign' 因为conduct draw的Type id是‘401’所以直接去voucherall_campaign_type去取campaign类型的信息就可以了
INSERT INTO $this->db_central.overall_campaign (overall_campaignName,overall_campaignType,customerId,createTime,modTime,startTime,remarks, overall_campaignStatus) SELECT overall_campaignTypeName,overall_campaignTypeId, '$this->customer_id', NOW(), NOW(), NOW(),description, 3 FROM $this->db_central.overall_campaign_type WHERE overall_campaignTypeId='401'
记录新插入的overall_campaignId
2.update 我们自定义的campaign name 到overall_campaign里 更新刚才insert的那条记录
3. 插入新的记录到‘db_central.luckydraw_drawcampaign’
这一步把这个draw的winner个数和reserve个数等创建,获奖人个数和draw的开始结束时间都在这个表里
INSERT INTO $this->db_central.luckydraw_drawcampaign (overall_campaignId,customerId,draw_campaignStatus, luckydraw_campaignId, winner_number, winner_type, reserve_number, reserve_type, condition_startTime, condition_endTime) SELECT overall_campaignId, customerId, 0, $this->luckydraw_campaignId, $winner_number, 'Segment', $reserve_number, 'Total', '$srart_time', '$end_time' FROM $this->db_central.overall_campaign WHERE overall_campaignId='$overall_campaignId'
4.获得新建的luckydraw_draw_campaignId
5.在客户的数据库里插入 campaign_lookup
INSERT INTO $this->customer_db_name.campaign_lookup (campaign_date,luckydraw_draw_campaignId) VALUES ('$campaign_date', $luckydraw_draw_campaignId)
得到$campaign_lookup_id
6.在客户数据库里插入 luckydraw_draw_settings
INSERT INTO $this->customer_db_name.luckydraw_draw_settings (luckydraw_draw_campaignId,prize_index,prize_description,winner_number,reserve_number) VALUES ('$luckydraw_draw_campaignId', 1, '$prize_description', $winner_number, $reserve_number)