Shopline Core Instruction === ###### tags: `Shopline` ``` # Connect into machine first ssh ec2-user@sa1.shoplinestg.com sa22 ``` 發放 birthday user_credit --- ``` ex. user_data['_id'] = 5d0c95a501afcd5f1a22820e user_credit_rule.id = 5cadb983e388096216d42760 rails c CreateBirthdayCreditJob.create(user_data['_id'], user_credit_rule.id) ``` NOTE. - How to get user_credit_rule? - browse [user_credit_rules](http://admin.sw22.shoplinestg.com/admin/shoplytics2/promotions/user_credit_rules) and check the [API](http://admin.sw22.shoplinestg.com/api/admin/v1/5bea48bff0ba0c0001964090/user_credit_rules?limit=24&page=1) 過期 user_criedt --- *不得為「永不過期」 [api.shoplineapp.com/lib/tasks/membership.rake](https://bitbucket.org/starlinglabs/api.shoplineapp.com/src/a87d760d625c7416e395e2145600d2c09fc79306/lib/tasks/membership.rake#lines-92) ``` rails c user_credit = User.find('5c10856c01afcd64fc8e9dfa').user_credits[-1] user_credit.end_at = Time.now - 10.days user_credit.save(validate: false) UserCredit::ExpireJob.expire('5c10856c01afcd64fc8e9dfa') ``` 修改 UserCredit萬年end_at --- ``` UserCredit.where(:end_at.gte => Date.new(10000,1,1)).count => 2 ucs = UserCredit.where(:end_at.gte => Date.new(10000,1,1)).to_a UserCredit.find '5d24097ecb1ad0001e09dc5f' => #<UserCredit _id: 5d24097ecb1ad0001e09dc5f, created_at: "2019-07-09T03:26:54.928Z", status: "active", is_redeem: false, value: 100, credit_balance: 100, performer_id: BSON::ObjectId('5aa5fde000fdde118000016e'), performer_type: "User", remarks: nil, type: "welcome_credit", order_id: nil, user_id: BSON::ObjectId('5d24097e31ffc7721e1cac6a'), user_credit_rule_id: nil, start_at: nil, end_at: "2739926-07-11T23:59:59.000Z", redeemed_user_credit_id: nil> 方法一 ucs[0].end_at = '2020-07-11T15:59:59.000Z' ucs[0].save(validate: false) 方法二 ucs = UserCredit.where(:end_at.gte => Date.new(10000,1,1)).first.set(end_at: '2020-07-11') ``` update後再到 [api](https://admin.shoplineapp.com/api/admin/v1/5aa5fde000fdde118000016e/users/5d24097e31ffc7721e1cac6a/user_credits) 確認時間 List rake --- 此部分的動作會影響整個機器所有Merchants ``` bundle exec rake -T ``` Trigger users import --- ``` bundle exec rake backburner:simple:work ```