Showing
1 changed file
with
10 additions
and
16 deletions
@@ -771,47 +771,41 @@ class AdminModel extends global.yoho.BaseModel { | @@ -771,47 +771,41 @@ class AdminModel extends global.yoho.BaseModel { | ||
771 | * @returns {*} | 771 | * @returns {*} |
772 | */ | 772 | */ |
773 | async sendWechatMessage(id, channel = 0) { | 773 | async sendWechatMessage(id, channel = 0) { |
774 | - | ||
775 | let info = await Promise.all([ | 774 | let info = await Promise.all([ |
776 | mysqlCli.query(`select name from ${TABLE_ACT_PRIZE_PRODUCT} | 775 | mysqlCli.query(`select name from ${TABLE_ACT_PRIZE_PRODUCT} |
777 | where id = :id limit 1`, {id}), | 776 | where id = :id limit 1`, {id}), |
778 | - mysqlCli.query(`select uid from ${TABLE_ACT_PRIZE_PRODUCT_USER} | 777 | + mysqlCli.query(`select distinct uid from ${TABLE_ACT_PRIZE_PRODUCT_USER} |
779 | where act_prize_id = :id`, {id}) | 778 | where act_prize_id = :id`, {id}) |
780 | ]); | 779 | ]); |
781 | 780 | ||
782 | - | ||
783 | let productInfo = _.get(info, '[0][0]'); | 781 | let productInfo = _.get(info, '[0][0]'); |
784 | let userList = []; | 782 | let userList = []; |
785 | - const miniAppType = ((+channel) === 1 ? 63 : 0); | ||
786 | - const baseUrl = miniAppType ? 'pages/zeroSell/detail' : 'page/subPackage/pages/zeroSell/detail'; | ||
787 | 783 | ||
788 | _.forEach(_.get(info, '[1]', []), value => { | 784 | _.forEach(_.get(info, '[1]', []), value => { |
789 | userList.push(value.uid); | 785 | userList.push(value.uid); |
790 | }); | 786 | }); |
791 | 787 | ||
792 | - userList = _.compact(_.uniq(userList)); | ||
793 | - | ||
794 | let msgApi = []; | 788 | let msgApi = []; |
795 | let msgData = { | 789 | let msgData = { |
796 | method: 'wechat.message.send', | 790 | method: 'wechat.message.send', |
797 | sendScene: 'MINI_WINNING_NOTICE', | 791 | sendScene: 'MINI_WINNING_NOTICE', |
798 | - | ||
799 | - // miniAppType: ((+channel) === 1 ? 63 : 29), | ||
800 | - miniAppType, | 792 | + miniAppType: ((+channel) === 1 ? 63 : 29), |
801 | params: JSON.stringify({ | 793 | params: JSON.stringify({ |
802 | activityTitle: productInfo.name, | 794 | activityTitle: productInfo.name, |
803 | activityTime: moment().format('YYYY-MM-DD HH:mm') + ':00', | 795 | activityTime: moment().format('YYYY-MM-DD HH:mm') + ':00', |
804 | - pageUrl: `${baseUrl}?actPrizeId=${id}` | ||
805 | - | ||
806 | - // pageUrl: 'pages/zeroSell/detail?actPrizeId=' + id | 796 | + pageUrl: 'pages/zeroSell/detail?actPrizeId=' + id |
807 | }) | 797 | }) |
808 | }; | 798 | }; |
809 | 799 | ||
810 | _.forEach(_.chunk(userList, NOTICE_BATCH_SEND_USER_NUM), value => { | 800 | _.forEach(_.chunk(userList, NOTICE_BATCH_SEND_USER_NUM), value => { |
801 | + value = _.compact(value); | ||
802 | + | ||
811 | if (value && value.length) { | 803 | if (value && value.length) { |
812 | - msgApi.push(this.get({data: Object.assign({uidList: value}, msgData)}).then(result => { | 804 | + msgApi.push(() => { |
805 | + return this.get({data: Object.assign({uidList: value}, msgData)}).then(result => { | ||
813 | logger.info(`zerobuy_winning_notice send ${result.code === 200 ? 'success' : 'fail'} uids: ${value.join(',')}`); | 806 | logger.info(`zerobuy_winning_notice send ${result.code === 200 ? 'success' : 'fail'} uids: ${value.join(',')}`); |
814 | - })); | 807 | + }); |
808 | + }); | ||
815 | } | 809 | } |
816 | }); | 810 | }); |
817 | 811 | ||
@@ -832,7 +826,7 @@ class AdminModel extends global.yoho.BaseModel { | @@ -832,7 +826,7 @@ class AdminModel extends global.yoho.BaseModel { | ||
832 | this.batchSend(_.drop(apis, NOTICE_BATCH_SEND_API_NUM)); | 826 | this.batchSend(_.drop(apis, NOTICE_BATCH_SEND_API_NUM)); |
833 | }, NOTICE_BATCH_SEND_INTERVAL); | 827 | }, NOTICE_BATCH_SEND_INTERVAL); |
834 | 828 | ||
835 | - return Promise.all(_.take(apis, NOTICE_BATCH_SEND_API_NUM)); | 829 | + return Promise.all(_.take(apis, NOTICE_BATCH_SEND_API_NUM).map(rp => rp())); |
836 | } | 830 | } |
837 | } | 831 | } |
838 | 832 |
-
Please register or login to post a comment